Skip to content
Logo

encodeEtherDeposit

Encodes an Ether deposit payload as the Ether portal does. This is the inverse of decodeEtherDeposit, useful for testing.

Usage

import {  } from "@cartesi/codec";
 
const  = ({
  : "0x92cc14432c1f82622493abd64d99ea8a3000a7c7",
  : 123456789n,
  : "0xdeadbeef",
});
// "0x92cc14432c1f82622493abd64d99ea8a3000a7c7000000...deadbeef"

Parameters

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.

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 sender (20 bytes) ‖ value (32 bytes) ‖ execLayerData.

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