Class: SolanaUtils
Defined in: solana-client/src/utils.ts:29
Solana's OvercastUtils: the whole boundary between base58 addresses and the canonical 32-byte slots core works in.
A Solana pubkey is already exactly 32 bytes, so toBytes32 and formatAddress are a pure re-encoding — no widening, no padding, and a clean round-trip in both directions. An address is valid iff it parses as a base58 PublicKey.
Stateless (no connection, no key), so a single shared instance is enough — see solanaUtils.
Implements
OvercastUtils
Constructors
Constructor
new SolanaUtils(): SolanaUtils;
Returns
SolanaUtils
Methods
formatAddress()
formatAddress(value): Address;
Defined in: solana-client/src/utils.ts:47
The inverse of toBytes32: a canonical slot back to this layer's address encoding, for display and for handing to the chain's own SDK.
Throws if the slot cannot be an address on this layer — e.g. an EVM layer given a slot with non-zero high bytes, which is a content-address or a digest rather than an account, and almost certainly a bug at the call site.
Parameters
| Parameter | Type |
|---|---|
value | Bytes32 |
Returns
Address
Implementation of
OvercastUtils.formatAddress
isValidAddress()
isValidAddress(value): boolean;
Defined in: solana-client/src/utils.ts:30
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
| Parameter | Type |
|---|---|
value | string |
Returns
boolean
Implementation of
OvercastUtils.isValidAddress
parseAddress()
parseAddress(value): Address;
Defined in: solana-client/src/utils.ts:39
Parse an untrusted string into this layer's canonical Address form, or throw.
The boundary check for anything the type system cannot vouch for: a CLI
argument, a wire payload, an address minted by another chain. Address is
structurally a string, so the compiler will happily hand a Solana layer an
EVM address; this is the call that catches it. Canonicalizing — trimming,
re-encoding to the chain's preferred casing — is part of the job, so the
result is safe to compare and display.
Parameters
| Parameter | Type |
|---|---|
value | string |
Returns
Address
Implementation of
OvercastUtils.parseAddress
toBytes32()
toBytes32(value): Bytes32;
Defined in: solana-client/src/utils.ts:43
A chain address as the canonical 32-byte slot core hashes and stores.
Throws if value is not a valid address on this layer — it performs the
same parse parseAddress does, so callers holding raw input can go
straight here.
Layers narrower than 32 bytes widen: an EVM address occupies the low 20 bytes of the slot, left-padded with zeros, exactly as its contracts do it.
Parameters
| Parameter | Type |
|---|---|
value | Address |
Returns
Bytes32
Implementation of
OvercastUtils.toBytes32