Skip to content
Logo

encodeErc721Deposit

Encodes an ERC-721 deposit payload as the ERC-721 portal does. This is the inverse of decodeErc721Deposit, useful for testing.

Usage

import {  } from "@cartesi/codec";
 
const  = ({
  : "0x67742ff5b2b762503ff0a92738c6fc2ea4a4d182",
  : "0x92cc14432c1f82622493abd64d99ea8a3000a7c7",
  : 42n,
  : "0x",
  : "0xdeadbeef",
});

Parameters

An Erc721Deposit object:

  • token (Address): token contract.
  • sender (Address): token sender.
  • tokenId (bigint): token identifier.
  • baseLayerData (Hex | Uint8Array): additional data to be interpreted by the base layer.
  • execLayerData (Hex | Uint8Array): additional data to be interpreted by the execution layer.

And an optional second parameter:

  • to ("hex" | "bytes", optional): representation of the encoded data. Defaults to "hex".

Return Type

Hex | Uint8Array: packed-encoded deposit payload, with layout token (20 bytes) ‖ sender (20 bytes) ‖ tokenId (32 bytes) ‖ abi.encode(baseLayerData, execLayerData).

Returns a Hex string by default, or a Uint8Array when to is "bytes".