Virtual TestNets are live! ⚡️ Test and stage dapps on real-time production data.
Get started →

All Products

Tenderly Node
Client Libraries
Ethers

Ethers.js - Tenderly Node Integration

Ethers.js is a standalone Typescript/Javascript for interacting with the Ethereum blockchain and its ecosystem.

To connect to a network through Tenderly Node using Ethers 6 or 5, you can use the JSON-RPC provider backed by HTTPS or WebSockets.

ethers-6/json-rpc-provider.ts
// Installation Instructions: https://docs.ethers.io/v6/getting-started
import { ethers } from "ethers";
 
const RPC_URL = `https://mainnet.gateway.tenderly.co/${process.env.TENDERLY_NODE_ACCESS_KEY}`
 
async function executeMethod() {
  // Initialize an ethers provider instance
  const provider = new ethers.JsonRpcProvider(RPC_URL);
 
  const blockNumber = await provider.getBlockNumber();
 
  console.log(blockNumber);
}
 
await executeMethod();

Using WebSocket provider

ethers-6/wss-provider.ts
// Installation Instructions: https://docs.ethers.io/v5/getting-started
import { ethers } from "ethers";
 
const RPC_URL = `https://mainnet.gateway.tenderly.co/${process.env.TENDERLY_NODE_ACCESS_KEY}`
 
async function executeMethod() {
  // Initialize an ethers provider instance
  const provider = new ethers.JsonRpcProvider(RPC_URL);
 
  const blockNumber = await provider.getBlockNumber();
 
  console.log(blockNumber);
}
 
await executeMethod();