TransactionEnvelopeEip7702.serialize
Serializes a TransactionEnvelopeEip7702.TransactionEnvelopeEip7702
.
Imports
Named
import { TransactionEnvelopeEip7702 } from 'ox'
Examples
import { Authorization, Secp256k1, TransactionEnvelopeEip7702, Value } from 'ox'
const authorization = Authorization.from({
address: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
chainId: 1,
nonce: 0n,
})
const signature = Secp256k1.sign({
payload: Authorization.getSignPayload(authorization),
privateKey: '0x...',
})
const authorizationList = [Authorization.from(authorization, { signature })]
const envelope = TransactionEnvelopeEip7702.from({
authorizationList,
chainId: 1,
maxFeePerGas: Value.fromGwei('10'),
to: '0x0000000000000000000000000000000000000000',
value: Value.fromEther('1'),
})
const serialized = TransactionEnvelopeEip7702.serialize(envelope)
Attaching Signatures
It is possible to attach a signature
to the serialized Transaction Envelope.
import { Secp256k1, TransactionEnvelopeEip7702, Value } from 'ox'
const envelope = TransactionEnvelopeEip7702.from({
authorizationList: [...],
chainId: 1,
maxFeePerGas: Value.fromGwei('10'),
to: '0x0000000000000000000000000000000000000000',
value: Value.fromEther('1'),
})
const signature = Secp256k1.sign({
payload: TransactionEnvelopeEip7702.getSignPayload(envelope),
privateKey: '0x...',
})
const serialized = TransactionEnvelopeEip7702.serialize(envelope, {
signature,
})
// ... send `serialized` transaction to JSON-RPC `eth_sendRawTransaction`
Definition
function serialize(
envelope: PartialBy<TransactionEnvelopeEip7702, 'type'>,
options?: serialize.Options,
): Serialized
Source: src/core/TransactionEnvelopeEip7702.ts
Parameters
envelope
- Type:
PartialBy<TransactionEnvelopeEip7702, 'type'>
The Transaction Envelope to serialize.
options
- Type:
serialize.Options
- Optional
Options.
options.signature
- Type:
{ r: bigint; s: bigint; yParity: number; }
- Optional
Signature to append to the serialized Transaction Envelope.
Return Type
The serialized Transaction Envelope.
Serialized