Read & Decode
Read EVM smart contract state and decode ABI-encoded return values with Zafeguard components.
Read & Decode
Components for reading on-chain state and decoding ABI-encoded data — without sending any transactions.
Public RPC URLs enforce rate limits per IP address and can fail under concurrent load. Use a private endpoint (Alchemy, Infura, QuickNode, or self-hosted). See Connecting to any chain.
READ_EVM_CONTRACT
READ_EVM_CONTRACT Workflow Component
Call a read-only (view / pure) contract function using eth_call. Returns the raw ABI-encoded result — pipe into DECODE_EVM_FUNCTION_RESULT to extract the values.
Config
None.
Inputs
| Field | Type | Description |
|---|---|---|
jsonRpcUrl | string | JSON-RPC endpoint |
contractAddress | string | Target contract address |
calldata | string | ABI-encoded calldata (from BUILD_EVM_CALLDATA) |
Outputs
| Field | Type | Description |
|---|---|---|
result | string | Raw ABI-encoded return data (hex) |
Example: read ERC-20 balance
BUILD_EVM_CALLDATA (balanceOf ABI, [holder_address])
│ calldata
▼
READ_EVM_CONTRACT (jsonRpcUrl, token_contract)
│ result
▼
DECODE_EVM_FUNCTION_RESULT (balanceOf ABI, result)
│
▼ balance (uint256 as string)
DECODE_EVM_FUNCTION_RESULT
DECODE_EVM_FUNCTION_RESULT Workflow Component
ABI-decode the raw bytes returned from a contract call into typed values.
Config
| Field | Type | Required | Description |
|---|---|---|---|
functionName | string | Yes | Name of the function whose return type should be used for decoding (e.g. "balanceOf") |
Inputs
| Field | Type | Description |
|---|---|---|
abi | AbiItem[] | ABI containing the function definition |
encodedResult | string | Raw hex-encoded return data (output of READ_EVM_CONTRACT) |
Outputs
Outputs are dynamic — one output per return value in the function's ABI definition. They are indexed as 0, 1, 2, etc. (matching the order of outputs in the ABI).
| Field | Type | Description |
|---|---|---|
0 | depends on ABI | First decoded return value |
1 | depends on ABI | Second decoded return value (if any) |
... | depends on ABI | Additional return values |
SDK example
import { WorkspaceClient, ComponentModule } from '@zafeguard/caller-sdk';
const workspace = new WorkspaceClient({ apiKey: process.env.ZAFEGUARD_API_KEY! });
// 1. Encode balanceOf(address) call
const calldata = await workspace.call(ComponentModule.BUILD_EVM_CALLDATA, {
abi: [{
type: 'function',
name: 'balanceOf',
inputs: [{ name: 'account', type: 'address' }],
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'view',
}],
args: ['0xHolderAddress'],
}).promise();
// 2. Read contract
const raw = await workspace.call(ComponentModule.READ_EVM_CONTRACT, {
jsonRpcUrl: 'https://eth-mainnet.g.alchemy.com/v2/KEY',
contractAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
calldata: calldata.calldata,
}).promise();
// 3. Decode
const decoded = await workspace.call(ComponentModule.DECODE_EVM_FUNCTION_RESULT, {
abi: [/* same ABI */],
encodedResult: raw.result,
}).promise();
console.log(decoded.decoded[0]); // "1000000" (1 USDC)EVM_KECCAK256
EVM_KECCAK256 Workflow Component
Compute the keccak256 hash of any hex-encoded data. Used for signature preimages, topic filters, and function selectors.
Config
None.
Inputs
| Field | Type | Description |
|---|---|---|
data | string | Hex-encoded data to hash (0x... or without prefix) |
Outputs
| Field | Type | Description |
|---|---|---|
hash | string | keccak256 hash (0x..., 32 bytes) |
SDK example
import { WorkspaceClient, ComponentModule } from '@zafeguard/caller-sdk';
const workspace = new WorkspaceClient({ apiKey: process.env.ZAFEGUARD_API_KEY! });
const hash = await workspace.call(ComponentModule.EVM_KECCAK256, {
data: '0x095ea7b3', // approve(address,uint256) selector input
}).promise();
console.log(hash.hash); // "0x..."EVM Cross-Chain Bridges
Bridge tokens across EVM chains in a single source-chain transaction. Fully decentralized — no API key, on-chain quotes only, auto-routed to the cheapest path.
Overview
Zafeguard Bitcoin components for the full transaction lifecycle — address derivation, UTXO selection, signing, and broadcasting.