This is a minimal example showing how to use Wormhole Queries to fetch and verify the name() of an ERC-20 token on Ethereum Sepolia using a Guardian-signed eth_call.
- Connects to Ethereum Sepolia via public RPC
- Queries the
name()function on a target ERC-20 contract - Sends the query to the Wormhole Query Proxy
- Receives a verifiable Guardian-signed response (Query VAA)
- Decodes the token name from the response
- Node.js 18+
- An API key for the Wormhole Query Proxy
-
Clone the repo or copy the script into your project
-
Install dependencies
npm install
-
Create a
.envfile with your API key:API_KEY=your_query_api_key_here
-
Run the script:
npm run query
You should see output like:
npm run query
> wormhole-query-demo@1.0.0 query
> tsx src/query.ts
π Fetching latest block from Sepolia...
β
Latest block: 8186366 (0x7ce9fe)
π Issuing Wormhole query...
π¦ Query Proxy response received
π Parsed chain response:
{
blockNumber: '8186366',
blockHash: '0x1008dfc2130b5196040f85ced943403839c586296025a20325e7179fb70ab68c',
result: '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000045553444300000000000000000000000000000000000000000000000000000000'
}
β
Token Name: USDCwormhole-query-demo/
βββ src/
β βββ query.ts # Main script
βββ .env # Your API key
βββ package.json
βββ tsconfig.json