TxEnvelopeLegacy.hash
Hashes a TxEnvelopeLegacy.TxEnvelopeLegacy. This is the "transaction hash".
Imports
Named
import { TxEnvelopeLegacy } from 'ox'Examples
import { Secp256k1, TxEnvelopeLegacy } from 'ox'
const envelope = TxEnvelopeLegacy.from({
chainId: 1,
nonce: 0n,
gasPrice: 1000000000n,
gas: 21000n,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n,
})
const signature = Secp256k1.sign({
payload: TxEnvelopeLegacy.getSignPayload(envelope),
privateKey: '0x...'
})
const envelope_signed = TxEnvelopeLegacy.from(envelope, { signature })
const hash = TxEnvelopeLegacy.hash(envelope_signed)Definition
function hash<presign>(
envelope: TxEnvelopeLegacy<presign extends true ? false : true>,
options?: hash.Options<presign>,
): hash.ReturnTypeSource: src/core/TxEnvelopeLegacy.ts
Parameters
envelope
- Type:
TxEnvelopeLegacy<presign extends true ? false : true>
The Legacy Transaction Envelope to hash.
envelope.gasPrice
- Type:
bigintType - Optional
Base fee per gas.
options
- Type:
hash.Options<presign> - Optional
Options.
options.presign
- Type:
boolean | presign - Optional
Whether to hash this transaction for signing.
Return Type
The hash of the transaction envelope.
hash.ReturnType

