decodeErc1155BatchDeposit
Decodes the payload of an input added by the ERC-1155 batch portal (depositBatchERC1155Token).
Portal deposit payloads are packed-encoded (abi.encodePacked) by the rollups contracts InputEncoding library, with layout token (20 bytes) ‖ sender (20 bytes) ‖ abi.encode(tokenIds, values, baseLayerData, execLayerData). There is no function selector, so make sure the input's msgSender is the ERC-1155 batch portal before decoding its payload.
Usage
import { , } from "@cartesi/codec";
const = ("0x...");
const = (.);
// {
// token: "0x...",
// sender: "0x...",
// tokenIds: [1n, 2n, 3n],
// values: [100n, 200n, 300n],
// baseLayerData: "0x",
// execLayerData: "0xdeadbeef",
// }Parameters
payload(Hex | Uint8Array): packed-encoded deposit payload (thepayloadfield of a decoded input).
Return Type
A Erc1155BatchDeposit object:
token(Address): token contract.sender(Address): token sender.tokenIds(readonly bigint[]): identifiers of the tokens being transferred.values(readonly bigint[]): transfer amounts per token type.baseLayerData(Hex | Uint8Array): additional data to be interpreted by the base layer.execLayerData(Hex | Uint8Array): additional data to be interpreted by the execution layer.
Addresses are returned checksummed.
Byte fields follow the representation of the encoded data: hex string in, hex string out; byte array in, byte array out. When decoding from a Uint8Array, the returned byte fields are zero-copy subarrays of the input — no data is copied.
Errors
Throws an Error if the payload is shorter than 40 bytes, or a viem decoding error if the data tail is malformed.