encodeInput
Encodes an input as an EvmAdvance call of the rollups contracts Inputs interface. This is the inverse of decodeInput, useful for testing.
Usage
import { } from "@cartesi/codec";
const = ({
: 1n,
: "0x0000000000000000000000000000000000000002",
: "0x0000000000000000000000000000000000000003",
: 4n,
: 5n,
: 6n,
: 7n,
: "0xdeadbeef",
});
// "0x415bf363000000...deadbeef00000..."Parameters
An Input object, with field names and types inferred from the EvmAdvance ABI:
chainId(bigint): chain id of the base layer.appContract(Address): address of the application contract.msgSender(Address): address of the input sender.blockNumber(bigint): base layer block number in which the input was added.blockTimestamp(bigint): base layer block timestamp (in seconds) in which the input was added.prevRandao(bigint):prevrandaovalue of the base layer block in which the input was added.index(bigint): index of the input in the application input box.payload(Hex | Uint8Array): application-specific payload of the input.
And an optional second parameter:
to("hex" | "bytes", optional): representation of the encoded data. Defaults to"hex".
Return Type
Hex | Uint8Array: ABI-encoded input data, starting with the EvmAdvance function selector (0x415bf363).
Returns a Hex string by default, or a Uint8Array when to is "bytes".