TxEnvelopeTempo.serialize
Serializes a TxEnvelopeTempo.TxEnvelopeTempo.
RLP-encodes the transaction with type prefix 0x76. For fee sponsorship, use format: 'feePayer' to serialize with the fee payer magic 0x78 and the sender address.
Imports
Named
import { TxEnvelopeTempo } from 'ox/tempo'Examples
import { Value } from 'ox'
import { TxEnvelopeTempo } from 'ox/tempo'
const envelope = TxEnvelopeTempo.from({
chainId: 1,
calls: [{
data: '0xdeadbeef',
to: '0x0000000000000000000000000000000000000000',
}],
maxFeePerGas: Value.fromGwei('10'),
})
const serialized = TxEnvelopeTempo.serialize(envelope)Attaching Signatures
It is possible to attach a signature to the serialized Transaction Envelope.
import { Secp256k1, Value } from 'ox'
import { TxEnvelopeTempo } from 'ox/tempo'
const envelope = TxEnvelopeTempo.from({
chainId: 1,
calls: [{
data: '0xdeadbeef',
to: '0x0000000000000000000000000000000000000000',
}],
maxFeePerGas: Value.fromGwei('10'),
})
const signature = Secp256k1.sign({
payload: TxEnvelopeTempo.getSignPayload(envelope),
privateKey: '0x...',
})
const serialized = TxEnvelopeTempo.serialize(envelope, {
signature,
})
// ... send `serialized` transaction to JSON-RPC `eth_sendRawTransaction`Definition
function serialize(
envelope: PartialBy<TxEnvelopeTempo, 'type'>,
options?: serialize.Options,
): SerializedSource: src/tempo/TxEnvelopeTempo.ts
Parameters
envelope
- Type:
PartialBy<TxEnvelopeTempo, 'type'>
The Transaction Envelope to serialize.
options
- Type:
serialize.Options - Optional
Options.
options.feePayerSignature
- Type:
{ r: bigint; s: bigint; yParity: number; } - Optional
Fee payer signature or the sender to cover the fee of.
- If
Signature.Signature, then this is the fee payer signature. - If
null, then this indicates the envelope is intended to be signed by a fee payer.
options.format
- Type:
"feePayer"
Whether to serialize the transaction in the fee payer format.
- If
'feePayer', then the transaction will be serialized in the fee payer format. - If
undefined(default), then the transaction will be serialized in the normal format.
options.sender
- Type:
abitype_Address
Sender address to cover the fee of.
options.signature
- Type:
Value - Optional
Sender signature to append to the serialized envelope.
Return Type
The serialized Transaction Envelope.
Serialized

