Skip to content

TxEnvelopeEip8141.getSignPayload

Returns the canonical signing payload of an EIP-8141 envelope.

Elides signature bytes only for entries with an empty payload. Explicit-payload signatures remain committed. The envelope is not mutated.

Imports

Named
import { TxEnvelopeEip8141 } from 'ox'

Examples

Signing

import {
  Address,
  FrameSignature,
  Secp256k1,
  TxEnvelopeEip8141
} from 'ox'
 
const privateKey = Secp256k1.randomPrivateKey()
const sender = Address.fromPublicKey(
  Secp256k1.getPublicKey({ privateKey })
)
const envelope = TxEnvelopeEip8141.from({
  chainId: 1,
  frames: [
    {
      executionGas: 50_000n,
      flags: 'approveExecutionAndPayment',
      mode: 'verify'
    }
  ],
  sender,
  signatures: [FrameSignature.from({ scheme: 'secp256k1' })]
})
 
const payload = TxEnvelopeEip8141.getSignPayload(envelope)
const signature = Secp256k1.sign({ payload, privateKey })
const signed = TxEnvelopeEip8141.from({
  ...envelope,
  signatures: [
    FrameSignature.from({ scheme: 'secp256k1', signature })
  ]
})

Definition

function getSignPayload(
  envelope: PartialBy<TxEnvelopeEip8141, 'type'>,
): Hex.Hex

Source: src/core/TxEnvelopeEip8141.ts

Parameters

envelope

  • Type: PartialBy<TxEnvelopeEip8141, 'type'>

The transaction envelope to sign.

Return Type

The canonical signing digest.

Hex.Hex