utils
Index
References
Namespaces
Enumerations
Classes
Type Aliases
Variables
Functions
- asciiToHex
- bytesToBuffer
- bytesToHex
- checkAddressCheckSum
- compareBlockNumbers
- convert
- convertScalarValue
- encodePacked
- format
- fromAscii
- fromDecimal
- fromTwosComplement
- fromUtf8
- fromWei
- getStorageSlotNumForLongString
- hexToAscii
- hexToBytes
- hexToNumber
- hexToNumberString
- hexToString
- hexToUtf8
- isAddress
- isBatchRequest
- isBatchResponse
- isBloom
- isContractAddressInBloom
- isDataFormat
- isHex
- isHexStrict
- isInBloom
- isNullish
- isPromise
- isResponseRpcError
- isResponseWithError
- isResponseWithNotification
- isResponseWithResult
- isSubscriptionResult
- isTopic
- isTopicInBloom
- isUserEthereumAddressInBloom
- isValidResponse
- keccak256Wrapper
- leftPad
- mergeDeep
- numberToHex
- padLeft
- padRight
- pollTillDefined
- processSolidityEncodePackedArgs
- randomBytes
- randomHex
- rejectIfConditionAtInterval
- rejectIfTimeout
- rightPad
- setRequestIdStart
- sha3
- sha3Raw
- soliditySha3
- soliditySha3Raw
- stringToHex
- toAscii
- toBatchPayload
- toBigInt
- toChecksumAddress
- toDecimal
- toHex
- toNumber
- toPayload
- toTwosComplement
- toUtf8
- toWei
- utf8ToHex
- uuidV4
- validateResponse
- waitWithTimeout
References
keccak256
Renames and re-exports keccak256Wrapper
Namespaces
jsonRpc
isBatchRequest
Parameters
request: JsonRpcBatchRequest | JsonRpcOptionalRequest<unknown> | JsonRpcRequest<unknown>
Returns request is JsonRpcBatchRequest
isBatchResponse
Type parameters
- Result = unknown
- Error_1 = unknown
Parameters
response: JsonRpcResponse<Result, Error_1>
Returns response is JsonRpcBatchResponse<Result, Error_1>
isResponseRpcError
Parameters
rpcError: JsonRpcResponseWithError<JsonRpcResult>
Returns boolean
isResponseWithError
Type parameters
- Error_1 = unknown
- Result = unknown
Parameters
response: JsonRpcResponse<Result, Error_1>
Returns response is JsonRpcResponseWithError<Error_1>
isResponseWithNotification
Type parameters
- Result
Parameters
response: JsonRpcSubscriptionResult | JsonRpcNotification<Result>
Returns response is JsonRpcNotification<Result>
isResponseWithResult
Type parameters
- Result = unknown
- Error_1 = unknown
Parameters
response: JsonRpcResponse<Result, Error_1>
Returns response is JsonRpcResponseWithResult<Result>
isSubscriptionResult
Type parameters
- Result
Parameters
response: JsonRpcSubscriptionResult | JsonRpcNotification<Result>
Returns response is JsonRpcSubscriptionResult
isValidResponse
Type parameters
- Result = unknown
- Error_1 = unknown
Parameters
response: JsonRpcResponse<Result, Error_1>
Returns boolean
setRequestIdStart
Parameters
start: undefined | number
Returns void
toBatchPayload
Parameters
requests: JsonRpcOptionalRequest<unknown>[]
Returns JsonRpcBatchRequest
toPayload
Type parameters
- ParamType = unknown[]
Parameters
request: JsonRpcOptionalRequest<ParamType>
Returns JsonRpcPayload<ParamType>
validateResponse
Type parameters
- Result = unknown
- Error_1 = unknown
Parameters
response: JsonRpcResponse<Result, Error_1>
Returns boolean
Enumerations
FMT_BYTES
BUFFER
HEX
UINT8ARRAY
FMT_NUMBER
BIGINT
HEX
NUMBER
STR
Classes
ChunkResponseParser
constructor
Returns ChunkResponseParser
onError
Parameters
optionalclearQueues: () => void
Returns void
parseResponse
Parameters
data: string
Returns JsonRpcResponse<JsonRpcResult, JsonRpcResult>[]
abstractEip1193Provider
Type parameters
- API: Web3APISpec = EthExecutionAPI
constructor
Type parameters
- API: unknown = EthExecutionAPI
Returns Eip1193Provider<API>
[symbol]
Returns boolean
abstractconnect
Returns void
abstractdisconnect
Parameters
optionalcode: number
optionaldata: string
Returns void
abstractgetStatus
Returns Web3ProviderStatus
abstracton
Parameters
type: disconnect
callback: Web3ProviderEventCallback<ProviderRpcError>
Returns void
optionalabstractonce
Type parameters
- T = JsonRpcResult
Parameters
type: string
callback: Web3ProviderEventCallback<T>
Returns void
optionalabstractremoveAllListeners
Parameters
type: string
Returns void
abstractremoveListener
Parameters
type: string
callback: Web3ProviderEventCallback<JsonRpcResult>
Returns void
abstractrequest
Type parameters
- Method: string
- ResultType = unknown
Parameters
args: Web3APIPayload<API, Method>
Returns Promise<JsonRpcResponseWithResult<ResultType>>
abstractreset
Returns void
send
Type parameters
- ResultType = JsonRpcResult
- P = unknown
Parameters
payload: JsonRpcPayload<P>
callback: (err?: null | Error, response?: JsonRpcResponse<ResultType, JsonRpcResult>) => void
Returns void
sendAsync
Type parameters
- R = JsonRpcResult
- P = unknown
Parameters
payload: JsonRpcPayload<P>
Returns Promise<JsonRpcResponse<R, JsonRpcResult>>
abstractsupportsSubscriptions
Returns boolean
staticisWeb3Provider
Parameters
provider: unknown
Returns boolean
abstractSocketProvider
Type parameters
- MessageEvent
- CloseEvent
- ErrorEvent
- API: Web3APISpec = EthExecutionAPI
constructor
Type parameters
- MessageEvent
- CloseEvent
- ErrorEvent
- API: unknown = EthExecutionAPI
Parameters
socketPath: string
optionalsocketOptions: object
optionalreconnectOptions: object
Returns SocketProvider<MessageEvent, CloseEvent, ErrorEvent, API>
SocketConnection
Returns unknown
[symbol]
Returns boolean
connect
Returns void
disconnect
Parameters
optionalcode: number
optionaldata: string
Returns void
abstractgetStatus
Returns Web3ProviderStatus
on
Type parameters
- T = JsonRpcResult
Parameters
type: string
callback: Web3ProviderEventCallback<T>
Returns void
once
Type parameters
- T = JsonRpcResult
Parameters
type: string
callback: Web3ProviderEventCallback<T>
Returns void
removeAllListeners
Parameters
type: string
Returns void
removeListener
Parameters
type: string
callback: Web3ProviderEventCallback<JsonRpcResult>
Returns void
request
Type parameters
- Method: string
- ResultType = Web3APIReturnType<API, Method>
Parameters
request: Web3APIPayload<API, Method>
Returns Promise<JsonRpcResponseWithResult<ResultType>>
reset
Returns void
send
Type parameters
- ResultType = JsonRpcResult
- P = unknown
Parameters
payload: JsonRpcPayload<P>
callback: (err?: null | Error, response?: JsonRpcResponse<ResultType, JsonRpcResult>) => void
Returns void
sendAsync
Type parameters
- R = JsonRpcResult
- P = unknown
Parameters
payload: JsonRpcPayload<P>
Returns Promise<JsonRpcResponse<R, JsonRpcResult>>
supportsSubscriptions
Returns boolean
staticisWeb3Provider
Parameters
provider: unknown
Returns boolean
Web3DeferredPromise
Type parameters
- T
constructor
Type parameters
- T
Parameters
optional__namedParameters: { eagerStart: boolean; timeout: number; timeoutMessage: string }
Returns Web3DeferredPromise<T>
[toStringTag]
state
Returns pending | fulfilled | rejected
catch
Type parameters
- TResult
Parameters
optionalonrejected: (reason: any) => TResult | PromiseLike<TResult>
Returns Promise<T | TResult>
finally
Parameters
optionalonfinally: () => void
Returns Promise<T>
reject
Parameters
optionalreason: unknown
Returns void
resolve
Parameters
value: T | PromiseLike<T>
Returns void
startTimer
Returns void
then
Type parameters
- TResult1
- TResult2
Parameters
optionalonfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>
optionalonrejected: (reason: unknown) => TResult2 | PromiseLike<TResult2>
Returns Promise<TResult1 | TResult2>
Type Aliases
AsyncFunction
Type parameters
- T
- K = unknown
Type declaration
Parameters
rest...args: K[]
Returns Promise<T>
ByteTypes
Type declaration
BYTES_BUFFER: Buffer
BYTES_HEX: HexString
BYTES_UINT8ARRAY: Uint8Array
DataFormat
Type declaration
readonlybytes: FMT_BYTES
readonlynumber: FMT_NUMBER
EtherUnits
FormatType
Type parameters
- T
- F: DataFormat
NumberTypes
Type declaration
NUMBER_BIGINT: bigint
NUMBER_HEX: HexString
NUMBER_NUMBER: number
NUMBER_STR: string
Variables
constDEFAULT_RETURN_FORMAT
Type declaration
readonlybytes: FMT_BYTES.HEX
readonlynumber: FMT_NUMBER.BIGINT
constETH_DATA_FORMAT
Type declaration
readonlybytes: FMT_BYTES.HEX
readonlynumber: FMT_NUMBER.HEX
constethUnitMap
Type declaration
Gwei: bigint
Kwei: bigint
Mwei: bigint
babbage: bigint
ether: bigint
femtoether: bigint
finney: bigint
gether: bigint
grand: bigint
gwei: bigint
kether: bigint
kwei: bigint
lovelace: bigint
mether: bigint
micro: bigint
microether: bigint
milli: bigint
milliether: bigint
mwei: bigint
nano: bigint
nanoether: bigint
noether: bigint
picoether: bigint
shannon: bigint
szabo: bigint
tether: bigint
wei: bigint
Functions
asciiToHex
Parameters
str: string
Returns string
bytesToBuffer
Parameters
data: Bytes
Returns Buffer
bytesToHex
Parameters
bytes: Bytes
Returns string
checkAddressCheckSum
Parameters
data: string
Returns boolean
compareBlockNumbers
Parameters
blockA: BlockNumberOrTag
blockB: BlockNumberOrTag
Returns 0 | 1 | -1
convert
Parameters
data: unknown
schema: JsonSchema
dataPath: string[]
format: DataFormat
optionaloneOfPath: [string, number][]
Returns unknown
convertScalarValue
Parameters
value: unknown
ethType: string
format: DataFormat
Returns unknown
encodePacked
Parameters
rest...values: Sha3Input[]
Returns string
format
Type parameters
- DataType: unknown
- ReturnType_1: DataFormat
Parameters
schema: JsonSchema | ValidationSchemaInput
data: DataType
returnFormat: ReturnType_1
Returns FormatType<DataType, ReturnType_1>
fromAscii
Parameters
str: string
Returns string
fromDecimal
Parameters
value: Numbers
Returns string
fromTwosComplement
Parameters
value: Numbers
optionalnibbleWidth: number
Returns number | bigint
fromUtf8
Parameters
str: string
Returns string
fromWei
Parameters
number: Numbers
unit: noether | wei | kwei | Kwei | babbage | femtoether | mwei | Mwei | lovelace | picoether | gwei | Gwei | shannon | nanoether | nano | szabo | microether | micro | finney | milliether | milli | ether | kether | grand | mether | gether | tether
Returns string
getStorageSlotNumForLongString
Parameters
mainSlotNumber: string | number
Returns undefined | string
hexToAscii
Parameters
str: string
Returns string
hexToBytes
Parameters
bytes: string
Returns Buffer
hexToNumber
Parameters
value: string
Returns number | bigint
hexToNumberString
Parameters
data: string
Returns string
hexToString
Parameters
str: string
Returns string
hexToUtf8
Parameters
str: string
Returns string
isAddress
Parameters
value: ValidInputTypes
optionalcheckChecksum: boolean
Returns boolean
isBatchRequest
Parameters
request: JsonRpcBatchRequest | JsonRpcOptionalRequest<unknown> | JsonRpcRequest<unknown>
Returns request is JsonRpcBatchRequest
isBatchResponse
Type parameters
- Result = unknown
- Error_1 = unknown
Parameters
response: JsonRpcResponse<Result, Error_1>
Returns response is JsonRpcBatchResponse<Result, Error_1>
isBloom
Parameters
bloom: ValidInputTypes
Returns boolean
isContractAddressInBloom
Parameters
bloom: string
contractAddress: string
Returns boolean
isDataFormat
Parameters
dataFormat: unknown
Returns dataFormat is DataFormat
isHex
Parameters
hex: ValidInputTypes
Returns boolean
isHexStrict
Parameters
hex: ValidInputTypes
Returns boolean
isInBloom
Parameters
bloom: string
value: string | Uint8Array
Returns boolean
isNullish
Parameters
item: unknown
Returns item is undefined | null
isPromise
Parameters
object: unknown
Returns boolean
isResponseRpcError
Parameters
rpcError: JsonRpcResponseWithError<JsonRpcResult>
Returns boolean
isResponseWithError
Type parameters
- Error_1 = unknown
- Result = unknown
Parameters
response: JsonRpcResponse<Result, Error_1>
Returns response is JsonRpcResponseWithError<Error_1>
isResponseWithNotification
Type parameters
- Result
Parameters
response: JsonRpcSubscriptionResult | JsonRpcNotification<Result>
Returns response is JsonRpcNotification<Result>
isResponseWithResult
Type parameters
- Result = unknown
- Error_1 = unknown
Parameters
response: JsonRpcResponse<Result, Error_1>
Returns response is JsonRpcResponseWithResult<Result>
isSubscriptionResult
Type parameters
- Result
Parameters
response: JsonRpcSubscriptionResult | JsonRpcNotification<Result>
Returns response is JsonRpcSubscriptionResult
isTopic
Parameters
topic: string
Returns boolean
isTopicInBloom
Parameters
bloom: string
topic: string
Returns boolean
isUserEthereumAddressInBloom
Parameters
bloom: string
ethereumAddress: string
Returns boolean
isValidResponse
Type parameters
- Result = unknown
- Error_1 = unknown
Parameters
response: JsonRpcResponse<Result, Error_1>
Returns boolean
keccak256Wrapper
Parameters
data: string | number | bigint | Buffer | ArrayBuffer | Uint8Array | readonly number[]
Returns string
leftPad
Parameters
value: Numbers
characterAmount: number
optionalsign: string
Returns string
mergeDeep
Parameters
destination: Record<string, unknown>
rest...sources: Record<string, unknown>[]
Returns Record<string, unknown>
numberToHex
Parameters
value: Numbers
Returns string
padLeft
Parameters
value: Numbers
characterAmount: number
optionalsign: string
Returns string
padRight
Parameters
value: Numbers
characterAmount: number
optionalsign: string
Returns string
pollTillDefined
Type parameters
- T
Parameters
func: AsyncFunction<T, unknown>
interval: number
Returns Promise<Exclude<T, undefined>>
processSolidityEncodePackedArgs
Parameters
arg: Sha3Input
Returns string
randomBytes
Parameters
byteSize: number
Returns Buffer
randomHex
Parameters
byteSize: number
Returns string
rejectIfConditionAtInterval
Type parameters
- T
Parameters
cond: AsyncFunction<undefined | T, unknown>
interval: number
Returns [NodeJS.Timer, Promise<never>]
rejectIfTimeout
Parameters
timeout: number
error: Error
Returns [NodeJS.Timer, Promise<never>]
rightPad
Parameters
value: Numbers
characterAmount: number
optionalsign: string
Returns string
setRequestIdStart
Parameters
start: undefined | number
Returns void
sha3
Parameters
data: Bytes
Returns undefined | string
sha3Raw
Parameters
data: Bytes
Returns string
soliditySha3
Parameters
rest...values: Sha3Input[]
Returns undefined | string
soliditySha3Raw
Parameters
rest...values: TypedObject[] | TypedObjectAbbreviated[]
Returns string
stringToHex
Parameters
str: string
Returns string
toAscii
Parameters
str: string
Returns string
toBatchPayload
Parameters
requests: JsonRpcOptionalRequest<unknown>[]
Returns JsonRpcBatchRequest
toBigInt
Parameters
value: unknown
Returns bigint
toChecksumAddress
Parameters
address: string
Returns string
toDecimal
Parameters
value: string
Returns number | bigint
toHex
Parameters
value: string | number | bigint | boolean | object | Buffer | ArrayBuffer | Uint8Array
optionalreturnType: boolean
Returns string
toNumber
Parameters
value: Numbers
Returns number | bigint
toPayload
Type parameters
- ParamType = unknown[]
Parameters
request: JsonRpcOptionalRequest<ParamType>
Returns JsonRpcPayload<ParamType>
toTwosComplement
Parameters
value: Numbers
optionalnibbleWidth: number
Returns string
toUtf8
Parameters
str: string
Returns string
toWei
Parameters
number: Numbers
unit: noether | wei | kwei | Kwei | babbage | femtoether | mwei | Mwei | lovelace | picoether | gwei | Gwei | shannon | nanoether | nano | szabo | microether | micro | finney | milliether | milli | ether | kether | grand | mether | gether | tether
Returns string
utf8ToHex
Parameters
str: string
Returns string
uuidV4
Returns string
validateResponse
Type parameters
- Result = unknown
- Error_1 = unknown
Parameters
response: JsonRpcResponse<Result, Error_1>
Returns boolean
waitWithTimeout
Type parameters
- T
Parameters
awaitable: Promise<T> | AsyncFunction<T, unknown>
timeout: number
error: Error
Returns Promise<T>