What you’ll be able to do
- Connect an application to Metal Testnet.
- Verify the chain ID and confirm that blocks are advancing.
Get an RPC endpoint
Follow Create an RPC endpoint to configure testnet billing and obtain an endpoint URL from the Metal console. This procedure does not require the quickstart’s command-line tools. SetMETAL_RPC_URL in the terminal that runs the application, replacing the
placeholder with the full URL copied from the console:
METAL_RPC_URL through its environment or secret
configuration. Keep endpoint URLs out of source control and application logs.
Add a client
Use Node.js 22 or later and pnpm 10.4 or later. Add the client to an existing project without replacing its package or compiler configuration. To start a new project:--allow-build=esbuild option permits the build step required by tsx.
Review it against the project’s dependency policy.
Viem’s public client handles these read requests. Later guides introduce
the Metal SDK for Metal-specific transaction
signing and encoding.
Initialize the public client
A public client needs only the endpoint URL. Reading chain data requires no signing key.Check the network
Check block progress
Use the same client and bypass its block-number cache for each sample:Run and check the result
Run these checks when initializing the connection. To run them separately, put the code in order incheck-connection.mts and add
console.log({ chainId, firstBlock, laterBlock }) at the end.
The .mts extension enables ES modules and top-level await. The command below
uses --ignoreConfig to check this file with explicit compiler options, leaving
the project’s tsconfig.json unchanged.
63825 and a laterBlock greater than
firstBlock.
Check the failure paths separately. Running with METAL_RPC_URL="" should stop
before any RPC request. An in-process mock returning 0x1 for eth_chainId
should trigger the wrong-network error. Use the live endpoint for the successful
connection check.
In a service, catch provider errors at the application boundary and redact
endpoint URLs before logging them.
Diagnose connection failures
Once this check passes, the application can read Metal through its public
client. Before submitting transactions, choose a signing account and
fund it using the Faucet.