TransactionEnvelopeEip4844.serialize
Serializes a TransactionEnvelopeEip4844.TransactionEnvelopeEip4844
.
Imports
Named
import { TransactionEnvelopeEip4844 } from 'ox'
Examples
import { Blobs, TransactionEnvelopeEip4844 } from 'ox'
import { kzg } from './kzg'
const blobs = Blobs.from('0xdeadbeef')
const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
const envelope = TransactionEnvelopeEip4844.from({
blobVersionedHashes,
chainId: 1,
maxFeePerGas: Value.fromGwei('10'),
to: '0x0000000000000000000000000000000000000000',
value: Value.fromEther('1'),
})
const serialized = TransactionEnvelopeEip4844.serialize(envelope)
Attaching Signatures
It is possible to attach a signature
to the serialized Transaction Envelope.
import { Blobs, Secp256k1, TransactionEnvelopeEip4844, Value } from 'ox'
import { kzg } from './kzg'
const blobs = Blobs.from('0xdeadbeef')
const sidecars = Blobs.toSidecars(blobs, { kzg })
const blobVersionedHashes = Blobs.sidecarsToVersionedHashes(blobs)
const envelope = TransactionEnvelopeEip4844.from({
blobVersionedHashes,
chainId: 1,
maxFeePerBlobGas: Value.fromGwei('3'),
maxFeePerGas: Value.fromGwei('10'),
maxPriorityFeePerGas: Value.fromGwei('1'),
to: '0x0000000000000000000000000000000000000000',
value: Value.fromEther('1'),
})
const signature = Secp256k1.sign({
payload: TransactionEnvelopeEip4844.getSignPayload(envelope),
privateKey: '0x...',
})
const serialized = TransactionEnvelopeEip4844.serialize(envelope, {
sidecars,
signature,
})
// ... send `serialized` transaction to JSON-RPC `eth_sendRawTransaction`
Definition
function serialize(
envelope: PartialBy<TransactionEnvelopeEip4844, 'type'>,
options?: serialize.Options,
): Serialized
Source: src/TransactionEnvelopeEip4844.ts
Parameters
envelope
- Type:
PartialBy<TransactionEnvelopeEip4844, 'type'>
The Transaction Envelope to serialize.
options
- Type:
serialize.Options
- Optional
Options.
options.sidecars
- Type:
BlobSidecars
- Optional
Sidecars to append to the serialized Transaction Envelope.
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
Error Type
TransactionEnvelopeEip4844.serialize.ErrorType