> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tenderly.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Ethers.js

> 了解如何使用 Ethers.js 通过 Node RPC 连接到区块链网络。

[Ethers.js](https://docs.ethers.org/v5/) 是一个独立的 Typescript/Javascript 库，可用于与 Virtual Environments 交互。

当您通过 **Public RPC** 连接时可以使用标准 RPC 方法，或者当您使用 **Admin RPC** 连接时可以使用 [Admin RPC](/virtual-environments/admin-rpc)。

<Card title="Code samples: Using Ethers with Virtual Environments" href="" />

```typescript title="virtual-environments/src/ethers-6-https.ts" showLineNumbers lines={4-5, 9, 15, 21, 28, 35, 41} theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}

const RPC_URL = process.env.VIRTUAL_MAINNET_RPC_URL || '';
const EXPLORER_BASE_URL = `https://dashboard.tenderly.co/explorer/vnet/${path.basename(RPC_URL)}`;

const provider = new JsonRpcProvider(RPC_URL);
(async () => {
    const ret = await Promise.all([
      provider.send('tenderly_setBalance', [
        ['0x0d2026b3EE6eC71FC6746ADb6311F6d3Ba1C000B', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'],
        '0xDE0B6B3A7640000',
      ]),

      // USDT
      provider.send('tenderly_setErc20Balance', [
        '0xdAC17F958D2ee523a2206206994597C13D831ec7',
        '0x40BdB4497614bAe1A67061EE20AAdE3c2067AC9e',
        '0xDE0B6B3A7640000',
      ]),

      // DAI
      provider.send('tenderly_setErc20Balance', [
        '0x6B175474E89094C44Da98b954EedeAC495271d0F',
        '0x40BdB4497614bAe1A67061EE20AAdE3c2067AC9e',
        '0xDE0B6B3A7640000',
      ]),
      // Shiba Inu
      provider.send('tenderly_setErc20Balance', [
        '0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE',
        '0x40BdB4497614bAe1A67061EE20AAdE3c2067AC9e',
        '0xDE0B6B3A7640000',
      ]),
    ]);
    console.log('ETH balance, DAI and ShibaInu topups', ret.map(txHash => `${EXPLORER_BASE_URL}/tx/${txHash}`));
  }
)().catch(e => {
  console.error(e);
  process.exitCode = 1;
});
```
