SHYNZ / Documentation

Read a Contract With Viem

Example of a read-only ERC-20 metadata call on an explicitly configured EVM network.

The sample below demonstrates the shape of a contract read using Viem. Supply a verified network, RPC endpoint, and ERC-20 contract address before executing it. No SHYNZ production address is implied.

import { createPublicClient, http, parseAbi } from 'viem';
import { mainnet } from 'viem/chains';
 
const client = createPublicClient({
  chain: mainnet,
  transport: http(), // Replace with your approved RPC as needed.
});
 
// Example shape only — configure a real, verified token contract.
// const token = '0x...' as `0x${string}`;
// const symbol = await client.readContract({
//   address: token,
//   abi: parseAbi(['function symbol() view returns (string)']),
//   functionName: 'symbol',
// });

A read-only call can still involve untrusted data or unreliable endpoints. Validate the address and network independently; do not assume that a matching token name implies authenticity.