Module utils

Source
Expand description

Common Ethereum utilities.

Structs§

Keccak256
Simple Keccak-256 hasher.
Unit
Ethereum unit. Always less than 77.

Enums§

ParseUnits
This enum holds the numeric types that a possible to be returned by parse_units and that are taken by format_units.
UnitsError
Error type for Unit-related operations.

Constants§

EIP191_PREFIX
The prefix used for hashing messages according to EIP-191.

Functions§

box_try_new
Allocates memory on the heap then places x into it, returning an error if the allocation fails.
box_try_new_uninit
Constructs a new box with uninitialized contents on the heap, returning an error if the allocation fails.
eip191_hash_message
Hash a message according to EIP-191 (version 0x01).
eip191_message
Constructs a message according to EIP-191 (version 0x01).
format_ether
Formats the given number of Wei as an Ether amount.
format_units
Formats the given number of Wei as the given unit.
keccak256
Simple interface to the Keccak-256 hash function.
parse_ether
Converts the input to a U256 and converts from Ether to Wei.
parse_units
Parses a decimal number and multiplies it with 10^units.
try_collect_vec
Tries to collect the elements of an iterator into a Vec.
vec_try_with_capacity
Tries to create a Vec with the given capacity.