Skip to content
Logo

decodeEtherDeposit

Decodes the payload of an input added by the Ether portal (depositEther).

Portal deposit payloads are packed-encoded (abi.encodePacked) by the rollups contracts InputEncoding library, with layout sender (20 bytes) ‖ value (32 bytes) ‖ execLayerData. There is no function selector, so make sure the input's msgSender is the Ether portal before decoding its payload.

Usage

import { ,  } from "@cartesi/codec";
 
const  = ("0x...");
const  = (.);
// {
//   sender: "0x...",
//   value: 123456789n,
//   execLayerData: "0xdeadbeef",
// }

Parameters

  • payload (Hex | Uint8Array): packed-encoded deposit payload (the payload field of a decoded input).

Return Type

An EtherDeposit object:

  • sender (Address): Ether sender.
  • value (bigint): amount of Wei being sent.
  • 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 52 bytes.