All Products

Tenderly Node
Interaction 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.mjs
// 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.mjs
// 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();