Skip to main content

web3-utils

Index

Classes

Enumerations

Functions

Interfaces

Namespaces

References

Type Aliases

Variables

References

keccak256

Renames and re-exports keccak256Wrapper

Type Aliases

AccessList

AccessList: AccessListItem[]

AccessListBuffer

AccessListBuffer: AccessListBufferItem[]

AccessListBufferItem

AccessListBufferItem: [Buffer, Buffer[]]

AccessListEIP2930ValuesArray

AccessListEIP2930ValuesArray: [Buffer, Buffer, Buffer, Buffer, Buffer, Buffer, Buffer, AccessListBuffer, Buffer?, Buffer?, Buffer?]

Buffer values array for an AccessListEIP2930Transaction

AccessListItem

AccessListItem: { address: PrefixedHexString; storageKeys: PrefixedHexString[] }

Type declaration

AccountBodyBuffer

AccountBodyBuffer: [Buffer, Buffer, Buffer | Uint8Array, Buffer | Uint8Array]

AddressLike

AddressLike: Address | Buffer | PrefixedHexString

A type that represents an input that can be converted to an Address.

AsyncFunction

AsyncFunction<T, K>: (...args: K[]) => Promise<T>

Type parameters

  • T
  • K = unknown

Type declaration

    • (...args: K[]): Promise<T>
    • Parameters

      • rest...args: K[]

      Returns Promise<T>

BigIntLike

BigIntLike: bigint | PrefixedHexString | number | Buffer

BufferLike

BufferLike: Buffer | Uint8Array | number[] | number | bigint | TransformableToBuffer | PrefixedHexString

ByteTypes

ByteTypes: { BYTES_BUFFER: Buffer; BYTES_HEX: HexString; BYTES_UINT8ARRAY: Uint8Array }

Type declaration

  • BYTES_BUFFER: Buffer
  • BYTES_HEX: HexString
  • BYTES_UINT8ARRAY: Uint8Array

DataFormat

DataFormat: { bytes: FMT_BYTES; number: FMT_NUMBER }

Type declaration

EtherUnits

EtherUnits: keyof typeof ethUnitMap

FeeMarketEIP1559ValuesArray

FeeMarketEIP1559ValuesArray: [Buffer, Buffer, Buffer, Buffer, Buffer, Buffer, Buffer, Buffer, AccessListBuffer, Buffer?, Buffer?, Buffer?]

Buffer values array for a FeeMarketEIP1559Transaction

FormatType

FormatType<T, F>: number extends Extract<T, Numbers> ? NumberTypes[F[number]] | Exclude<T, Numbers> : Buffer extends Extract<T, Bytes> ? ByteTypes[F[bytes]] | Exclude<T, Bytes> : T extends object | undefined ? { [ P in keyof T ]: FormatType<T[P], F> } : T

Type parameters

NestedBufferArray

NestedBufferArray: (Buffer | NestedBufferArray)[]

NestedUint8Array

NestedUint8Array: (Uint8Array | NestedUint8Array)[]

NumberTypes

NumberTypes: { NUMBER_BIGINT: bigint; NUMBER_HEX: HexString; NUMBER_NUMBER: number; NUMBER_STR: string }

Type declaration

  • NUMBER_BIGINT: bigint
  • NUMBER_HEX: HexString
  • NUMBER_NUMBER: number
  • NUMBER_STR: string

PrefixedHexString

PrefixedHexString: string

ReconnectOptions

ReconnectOptions: { autoReconnect: boolean; delay: number; maxAttempts: number }

Type declaration

  • autoReconnect: boolean
  • delay: number
  • maxAttempts: number

ToBufferInputTypes

ToBufferInputTypes: PrefixedHexString | number | bigint | Buffer | Uint8Array | number[] | TransformableToArray | TransformableToBuffer | null | undefined

TxData

TxData: { data?: BufferLike; gasLimit?: BigIntLike; gasPrice?: BigIntLike | null; nonce?: BigIntLike; r?: BigIntLike; s?: BigIntLike; to?: AddressLike; type?: BigIntLike; v?: BigIntLike; value?: BigIntLike }

Legacy Transaction Data


Type declaration

  • optionaldata?: BufferLike

    This will contain the data of the message or the init of a contract.

  • optionalgasLimit?: BigIntLike

    The transaction’s gas limit.

  • optionalgasPrice?: BigIntLike | null

    The transaction’s gas price.

  • optionalnonce?: BigIntLike

    The transaction’s nonce.

  • optionalr?: BigIntLike

    EC signature parameter.

  • optionals?: BigIntLike

    EC signature parameter.

  • optionalto?: AddressLike

    The transaction’s the address is sent to.

  • optionaltype?: BigIntLike

    The transaction type

  • optionalv?: BigIntLike

    EC recovery ID.

  • optionalvalue?: BigIntLike

    The amount of Ether sent.

TxValuesArray

TxValuesArray: Buffer[]

Buffer values array for a legacy Transaction

TypeOutputReturnType

TypeOutputReturnType: { 0: number; 1: bigint; 2: Buffer; 3: PrefixedHexString }

Type declaration

TypedTransaction

TypedTransaction: Transaction | AccessListEIP2930Transaction | FeeMarketEIP1559Transaction | BlobEIP4844Transaction

Encompassing type for all transaction types.

Note that this also includes legacy txs which are referenced as Transaction for compatibility reasons.

WithdrawalBuffer

WithdrawalBuffer: [Buffer, Buffer, Buffer, Buffer]

WithdrawalData

WithdrawalData: { address: AddressLike; amount: BigIntLike; index: BigIntLike; validatorIndex: BigIntLike }

Flexible input data type for EIP-4895 withdrawal data with amount in Gwei to match CL representation and for eventual ssz withdrawalsRoot


Type declaration

Variables

constAccessTupleType

AccessTupleType: ContainerType<{ address: ByteVectorType; storageKeys: ListCompositeType<ByteVectorType> }> = ...

constAddressType

AddressType: ByteVectorType = Bytes20

EIP4844 types

constBlobNetworkTransactionWrapper

BlobNetworkTransactionWrapper: ContainerType<{ blobKzgs: ListCompositeType<ByteVectorType>; blobs: ListCompositeType<ByteVectorType>; kzgAggregatedProof: ByteVectorType; tx: ContainerType<{ message: ContainerType<{ accessList: ListCompositeType<ContainerType<{ address: ByteVectorType; storageKeys: ListCompositeType<ByteVectorType> }>>; blobVersionedHashes: ListCompositeType<ByteVectorType>; chainId: UintBigintType; data: ByteListType; gas: UintBigintType; maxFeePerDataGas: UintBigintType; maxFeePerGas: UintBigintType; maxPriorityFeePerGas: UintBigintType; nonce: UintBigintType; to: UnionType<(ByteVectorType | NoneType)[]>; value: UintBigintType }>; signature: ContainerType<{ r: UintBigintType; s: UintBigintType; yParity: BooleanType }> }> }> = ...

constBlobTransactionType

BlobTransactionType: ContainerType<{ accessList: ListCompositeType<ContainerType<{ address: ByteVectorType; storageKeys: ListCompositeType<ByteVectorType> }>>; blobVersionedHashes: ListCompositeType<ByteVectorType>; chainId: UintBigintType; data: ByteListType; gas: UintBigintType; maxFeePerDataGas: UintBigintType; maxFeePerGas: UintBigintType; maxPriorityFeePerGas: UintBigintType; nonce: UintBigintType; to: UnionType<(ByteVectorType | NoneType)[]>; value: UintBigintType }> = ...

constDEFAULT_RETURN_FORMAT

DEFAULT_RETURN_FORMAT: { bytes: HEX; number: BIGINT } = ...

Type declaration

  • bytes: HEX
  • number: BIGINT

constECDSASignatureType

ECDSASignatureType: ContainerType<{ r: UintBigintType; s: UintBigintType; yParity: BooleanType }> = ...

constETH_DATA_FORMAT

ETH_DATA_FORMAT: { bytes: HEX; number: HEX } = ...

Type declaration

  • bytes: HEX
  • number: HEX

constGWEI_TO_WEI

GWEI_TO_WEI: bigint = ...

constKECCAK256_NULL

KECCAK256_NULL: Buffer = ...

Keccak-256 hash of null

constKECCAK256_NULL_S

KECCAK256_NULL_S: c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 = 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'

Keccak-256 hash of null

constKECCAK256_RLP

KECCAK256_RLP: Buffer = ...

Keccak-256 hash of the RLP of null

constKECCAK256_RLP_ARRAY

KECCAK256_RLP_ARRAY: Buffer = ...

Keccak-256 of an RLP of an empty array

constKECCAK256_RLP_ARRAY_S

KECCAK256_RLP_ARRAY_S: 1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 = '1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'

Keccak-256 of an RLP of an empty array

constKECCAK256_RLP_S

KECCAK256_RLP_S: 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 = '56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'

Keccak-256 hash of the RLP of null

constKZGCommitmentType

KZGCommitmentType: ByteVectorType = Bytes48

constKZGProofType

KZGProofType: ByteVectorType = KZGCommitmentType

constMAX_INTEGER

MAX_INTEGER: bigint = ...

The max integer that the evm can handle (2^256-1)

constMAX_INTEGER_BIGINT

MAX_INTEGER_BIGINT: bigint = ...

The max integer that the evm can handle (2^256-1) as a bigint 2^256-1 equals to 340282366920938463463374607431768211455 We use literal value instead of calculated value for compatibility issue.

constMAX_UINT64

MAX_UINT64: bigint = ...

2^64-1

constMAX_WITHDRAWALS_PER_PAYLOAD

MAX_WITHDRAWALS_PER_PAYLOAD: 16 = 16

constRLP_EMPTY_STRING

RLP_EMPTY_STRING: Buffer = ...

RLP encoded empty string

constSECP256K1_ORDER

SECP256K1_ORDER: bigint = CURVE.n

constSECP256K1_ORDER_DIV_2

SECP256K1_ORDER_DIV_2: bigint = ...

constSignedBlobTransactionType

SignedBlobTransactionType: ContainerType<{ message: ContainerType<{ accessList: ListCompositeType<ContainerType<{ address: ByteVectorType; storageKeys: ListCompositeType<ByteVectorType> }>>; blobVersionedHashes: ListCompositeType<ByteVectorType>; chainId: UintBigintType; data: ByteListType; gas: UintBigintType; maxFeePerDataGas: UintBigintType; maxFeePerGas: UintBigintType; maxPriorityFeePerGas: UintBigintType; nonce: UintBigintType; to: UnionType<(ByteVectorType | NoneType)[]>; value: UintBigintType }>; signature: ContainerType<{ r: UintBigintType; s: UintBigintType; yParity: BooleanType }> }> = ...

constTWO_POW256

TWO_POW256: bigint = ...

2^256