Skip to content
Logo

rollup.emitVoucher

Emits a voucher — a one-shot on-chain transaction authorized by the application: a destination, an ether value, and calldata. Once the epoch containing it settles, the voucher can be executed through the application contract, exactly once.

Encoded on-chain as Voucher(address,uint256,bytes) and added to the outputs merkle tree (provable).

Usage

Plain value transfer:

const  = .({
    : "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
    : 1_000_000_000_000_000_000n, // 1 ETH in wei
});

Contract call (calldata in payload):

.({
    : "0x6B175474E89094C44Da98b954EedeAC495271d0F",
    : ,
});

Returns

bigint — the output index: the voucher's position among all provable outputs ever emitted by the application. Off-chain components use it to fetch the voucher's proof for execution — it is the outputIndex of @cartesi/client.

Parameters

destination

  • Type: AddressLike — 0x-prefixed hex string, Buffer or Uint8Array
  • Required; must be exactly 20 bytes

The address the voucher executes against: an EOA for transfers, a contract for calls.

value

  • Type: U256Likebigint, number, or 32 bytes
  • Default: 0n

Amount of wei sent with the execution. Must fit in an unsigned 256-bit integer.

payload

  • Type: BytesLike — 0x-prefixed hex string, Buffer or Uint8Array
  • Default: empty

EVM calldata to execute at destination. Leave empty for a plain transfer.

Errors

ConditionError
destination not 20 bytes / malformed hexTypeError
value negative or ≥ 2²⁵⁶RangeError
Voucher larger than the machine's output bufferRollupError with negative errno