@oaknetwork/contracts-sdk or @oaknetwork/contracts-sdk/utils.
Hashing
keccak256(data)
Hashes a string, hex string, orUint8Array using keccak256.
id(input)
Produces a bytes32 hash from a UTF-8 string. Equivalent to Solidity’skeccak256(abi.encodePacked(str)).
Encoding
isHex(data)
Type guard that checks if a string is a valid0x-prefixed hex string.
toHex(value, options?)
Converts a value to a hex string. Pass{ size: 32 } for fixed-length bytes32 encoding.
stringToHex(value)
Converts a UTF-8 string to a hex string.isAddress(value)
Checks if a string is a valid Ethereum address.getAddress(value)
Returns the checksummed version of an address. Throws if invalid.Number formatting
parseEther(value)
Converts a human-readable ether string tobigint (wei).
formatEther(value)
Converts abigint (wei) to a human-readable ether string.
parseUnits(value, decimals)
Converts a human-readable string tobigint with the specified decimal places.
Time helpers
getCurrentTimestamp()
Returns the current Unix time as abigint in seconds.
addDays(timestamp, days)
Adds days to a Unix timestamp.Chain helpers
getChainFromId(chainId)
Resolves a numeric chain ID to a viemChain object. Falls back to a minimal definition for unknown IDs.
Browser wallet helpers
For frontend integrations:Constants
CHAIN_IDS
BPS_DENOMINATOR
Basis-points denominator for fee calculations.10_000n = 100%.
BYTES32_ZERO
Zero bytes32 value (0x0000...0000). Used as a default or unset marker.
DATA_REGISTRY_KEYS
Pre-computed keccak256 hashes for common registry keys:scopedToPlatform(baseKey, platformHash)
Computes a platform-scoped registry key. Matches the on-chainDataRegistryKeys.scopedToPlatform.
Multicall
Batch multiple read calls into a single RPC round-trip. Pass an array of lazy closures — the same entity read methods you’d normallyawait individually.
For full usage details including cross-contract batching, see the dedicated Multicall page.
Viem re-exports
The SDK re-exports commonly used viem primitives so you don’t need to install viem separately:| Export | Description |
|---|---|
createPublicClient | Create a viem PublicClient for reads |
createWalletClient | Create a viem WalletClient for writes |
http | HTTP transport factory |
custom | Custom transport factory |
mainnet | Ethereum mainnet chain config |
sepolia | Ethereum Sepolia chain config |
goerli | Ethereum Goerli chain config |