Skip to main content

Class: EvmUtils

Defined in: evm-client/src/utils.ts:70

EVM's OvercastUtils: the whole boundary between 0x… addresses and the canonical 32-byte slots core works in.

Unlike a layer whose addresses are already 32 bytes wide, this one widens and narrows: toBytes32 left-pads a 20-byte address into the low end of a slot, and formatAddress takes it back out, rejecting a slot whose high bytes are non-zero — that is a digest or a content-address, not an account. An address is valid iff parseAddress accepts it: 20 bytes of well-formed hex, in any casing.

Stateless (no client, no account), so a single shared instance is enough — see evmUtils, which the named helpers below are all expressed over.

Implements​

  • OvercastUtils

Constructors​

Constructor​

new EvmUtils(): EvmUtils;

Returns​

EvmUtils

Methods​

formatAddress()​

formatAddress(value): `0x${string}`;

Defined in: evm-client/src/utils.ts:119

A canonical slot back to the checksummed Address viem wants.

Throws when the slot's high bytes are not zero: that value cannot be an EVM account, so it is a content-address or digest that reached an address position — a bug at the call site, and one that would otherwise silently read some unrelated contract.

Parameters​

ParameterType
valueBytes32

Returns​

`0x${string}`

Implementation of​

OvercastUtils.formatAddress

isValidAddress()​

isValidAddress(value): boolean;

Defined in: evm-client/src/utils.ts:71

Whether value is a well-formed address on this layer. The non-throwing counterpart to parseAddress, for validating input as it is typed, where an exception is the wrong shape of answer.

Parameters​

ParameterType
valuestring

Returns​

boolean

Implementation of​

OvercastUtils.isValidAddress

parseAddress()​

parseAddress(value): `0x${string}`;

Defined in: evm-client/src/utils.ts:93

Parse an untrusted string as a checksummed 20-byte EVM Address, or throw.

Accepts any casing and normalizes to EIP-55, which is also what viem hands back when it decodes an address — so an address that made a round trip through a read compares equal to one that came from a config.

This is the entry point for the chain-encoded addresses that reach the SDK from outside core's canonical form: a deployment config, or the curated Asset.address (which is display data in the layer's own encoding, never a slot).

Parameters​

ParameterType
valuestring

Returns​

`0x${string}`

Implementation of​

OvercastUtils.parseAddress

toBytes32()​

toBytes32(value): Bytes32;

Defined in: evm-client/src/utils.ts:107

An EVM address as the canonical slot core hashes and stores: left-padded to 32 bytes and lower-cased, matching what the contracts widen an address to.

Parsed rather than padded straight: an Address is structurally a string, so a value that is no address at all would otherwise widen into a slot that hashes cleanly and matches nothing on chain. That strictness is why the 32-byte-tolerant toSlot stays separate rather than collapsing into this method.

Parameters​

ParameterType
valueAddress

Returns​

Bytes32

Implementation of​

OvercastUtils.toBytes32