encodeOutput
Encodes an output as one of the functions of the rollups contracts Outputs interface, based on its type field. This is the inverse of decodeOutput, useful for testing.
For encoding a specific output type, see encodeNotice, encodeVoucher and encodeDelegateCallVoucher.
Usage
import { } from "@cartesi/codec";
const = ({ : "Notice", : "0xdeadbeef" });
// "0xc258d6e5...deadbeef..."
const = ({
: "Voucher",
: "0x0000000000000000000000000000000000000001",
: 2n,
: "0xdeadbeef",
});
// "0x237a816f..."
const = ({
: "DelegateCallVoucher",
: "0x0000000000000000000000000000000000000001",
: "0xdeadbeef",
});
// "0x10321e8b..."Parameters
import type { } from "@cartesi/codec";
// type Output = DelegateCallVoucher | Notice | Voucher;And an optional second parameter:
to("hex" | "bytes", optional): representation of the encoded data. Defaults to"hex".
Return Type
Hex | Uint8Array: ABI-encoded output data.
Returns a Hex string by default, or a Uint8Array when to is "bytes".