TransactionEnvelopeLegacy.serialize
Serializes a TransactionEnvelopeLegacy.TransactionEnvelopeLegacy
.
Imports
Named
import { TransactionEnvelopeLegacy } from 'ox'
Examples
import { TransactionEnvelopeLegacy } from 'ox'
const envelope = TransactionEnvelopeLegacy.from({
chainId: 1,
gasPrice: Value.fromGwei('10'),
to: '0x0000000000000000000000000000000000000000',
value: Value.fromEther('1'),
})
const serialized = TransactionEnvelopeLegacy.serialize(envelope)
Attaching Signatures
It is possible to attach a signature
to the serialized Transaction Envelope.
import { Secp256k1, TransactionEnvelopeLegacy, Value } from 'ox'
const envelope = TransactionEnvelopeLegacy.from({
chainId: 1,
gasPrice: Value.fromGwei('10'),
to: '0x0000000000000000000000000000000000000000',
value: Value.fromEther('1'),
})
const signature = Secp256k1.sign({
payload: TransactionEnvelopeLegacy.getSignPayload(envelope),
privateKey: '0x...',
})
const serialized = TransactionEnvelopeLegacy.serialize(envelope, {
signature,
})
// ... send `serialized` transaction to JSON-RPC `eth_sendRawTransaction`
Definition
function serialize(
envelope: PartialBy<TransactionEnvelopeLegacy, 'type'>,
options?: serialize.Options,
): Serialized
Source: src/TransactionEnvelopeLegacy.ts
Parameters
envelope
- Type:
PartialBy<TransactionEnvelopeLegacy, '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.
Error Type
TransactionEnvelopeLegacy.serialize.ErrorType