Supported Assets
isSupported
isSupported
TypeScript Example
Note: This example assumes you have a publicClient configured in your code base. Please refer to https://viem.sh/docs/clients/public for detailed documentation.
import { createPublicClient, http, parseAbiItem, isAddress, type Address } from "viem";
import { mainnet } from "viem/chains";
// 1. The contract address and the ABI for the getter function
// Using 'as const' helps TypeScript infer the types more strictly.
const tellerAbi = [
/* ... (start of ABI) ... */
{
inputs: [{ internalType: "contract ERC20", name: "", type: "address" }],
name: "isSupported",
outputs: [{ internalType: "bool", name: "", type: "bool" }],
stateMutability: "view",
type: "function",
},
/* ... (rest of the ABI) ... */
] as const;
// --- Configuration ---
const tellerAddress = "0x..."; // <-- Vault Teller Address
// 1. Define an async function to call the contract
async function checkIsSupported(tokenAddress: Address) {
// A friendly message to indicate that the address needs to be replaced.
if (!isAddress(contractAddress)) {
console.error(
"Please replace '0x...' with your smart contract's address in the script.",
);
return;
}
try {
// 2. Use `readContract` to interact with the 'isSupported' view function
const isSupported = await publicClient.readContract({
address: tellerAddress,
abi: tellerAbi,
functionName: "isSupported",
// The 'args' array corresponds to the function's arguments.
// In this case, the public mapping's getter takes one argument: the address to look up.
args: [tokenAddress],
});
return isSupported;
} catch (err) {
console.error("Error reading from contract:", err);
}
}
// 5. Execute the function with the example token address
checkIsSupported(usdcAddress);
Last updated