Get started with ethers CDN

MIT licensed

Decentralized, open-source platforms for Ethereum smart contracts and apps.

Tags:
  • ethers
  • ethereum
  • wallet
  • eth

Stable version

Copied!

How to start using ethers CDN


// Import Ethers.js library
const ethers = typeof window.ethers !== 'undefined' ? window.ethers : require('ethers');

// Set up provider (e.g., Infura)
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/your-project-id');

// Set up wallet
const wallet = new ethers.Wallet('your-private-key', provider);

// Get account balance
async function getBalance() {
  const balance = await wallet.getBalance();
  console.log('Account balance:', ethers.utils.formatEther(balance));
}

// Call the function
getBalance();
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions