Commands for encoding and decoding data in various formats.
compute decodeJWT <jwt>
Command to decode a JWT. It's also possible to load it from the saved variables by referencing its name.
Parameters:
- jwt: JWT to decode.
Examples:
compute decodeJWT eyJ0e...
compute decodeJWT myJwt
compute encodePublicKey <key> <options>
Command to encode a public key in a specific format.
Parameters:
- key: Key to encode. It can be a private or public key. The input format can be "hex" or "jwk".
- options: JSON containing the fields: algorithm "alg" (optional) and "format" to encode, which can be "hex", "jwk", or "pem".
Examples:
compute encodePublicKey 0x0434... {"format":"pem","alg":"ES256"}
compute encodePublicKey {"kty":"EC"...} {"format":"pem"}
compute encodePrivateKey <key> <options>
Command to encode a private key in a specific format.
Parameters:
- key: Private key to encode. The input format can be "hex" or "jwk".
- options: JSON containing the fields: algorithm "alg" (optional), "format" to encode (which can be "hex", "jwk", or "pem"), and "type" of pem format if pem is selected.
Examples:
compute encodePrivateKey 0x34... {"format":"pem","alg":"ES256","type":"sec1"}
compute encodePrivateKey {"kty":"EC"...} {"format":"hex"}
compute encodeBase64 <hex>
Command to encode data as base64.
Parameters:
- hex: Bytes encoded as hex string
compute encodeBase64url <hex>
Command to encode data as base64url.
Parameters:
- hex: Bytes encoded as hex string
compute decodeBase64 <data> <outputType>
Command to decode data encoded in base64. It's also possible to load it from the saved variables by referencing its name.
Parameters:
- data: Data to decode.
- outputType: Output type. It can be "buffer", "json", or "utf8" (default).
Examples:
compute decodeBase64 eyJ0e...
compute decodeBase64 myData
compute decodeBase64url <data>
Command to decode data encoded in base64url. It's also possible to load it from the saved variables by referencing its name.
Parameters:
- data: Data to decode.
Examples:
compute decodeBase64url eyJ0e...
compute decodeBase64url myData
compute decodeHex <data>
Command to decode data encoded as hex string. It's also possible to load it from the saved variables by referencing its name.
Parameters:
- data: Data to decode.
Examples:
compute decodeHex 0x41df...
compute decodeHex 41df...
compute encodeContractData <types> <data> <functionName>
Command to encode contract data for a specific smart contract function.
Parameters:
- types: Types of the parameters. See the ABI documentation for the types supported.
- data: Data to encode.
- functionName (optional): Name of the function or the function signature. If not provided, the function signature will not be encoded.
Examples:
==> compute encodeContractData ["address"] ["0x69e48d89bf5e09588E858D757323b4abBBB3f814"]
0x00000000000000000000000069e48d89bf5e09588e858d757323b4abbbb3f814
==> compute encodeContractData ["address"] ["0x69e48d89bf5e09588E858D757323b4abBBB3f814"] initialize(address)
0xc4d66de800000000000000000000000069e48d89bf5e09588e858d757323b4abbbb3f814
compute decodeContractData <types> <data> <hasFunction>
Command to decode contract data for a specific smart contract function.
Parameters:
- types: Types of the parameters. See the ABI documentation for the types supported.
- data: Data to decode.
- hasFunction: Whether the function signature is included in the data. By default, it is false.
Examples:
==> compute decodeContractData ["address"] 0x00000000000000000000000069e48d89bf5e09588e858d757323b4abbbb3f814
{
"data": [
"0x69e48d89bf5e09588E858D757323b4abBBB3f814"
]
}
==> compute decodeContractData ["address"] 0xc4d66de800000000000000000000000069e48d89bf5e09588e858d757323b4abbbb3f814 true
{
"data": [
"0x69e48d89bf5e09588E858D757323b4abBBB3f814"
],
"functionSig": "0xc4d66de8"
}