Aug 9, 2024
git clone <repository-url>
npm install
in the cloned directory.const ethers = require('ethers');
const provider = new ethers.providers.JsonRpcProvider('<infura-url>');
const balance = await provider.getBalance('<ethereum-address>');
console.log(ethers.utils.formatEther(balance));
const contract = new ethers.Contract(<contract-address>, <abi>, provider);
contract.name()
or contract.symbol()
to fetch data.const wallet = new ethers.Wallet(<private-key>, provider);
const tx = await wallet.sendTransaction({ to: <receiver-address>, value: ethers.utils.parseEther('0.025') });
const tokenContract = new ethers.Contract(<token-address>, <erc20-abi>, wallet);
const tx = await tokenContract.transfer(<receiver-address>, ethers.utils.parseUnits('10', 18));
const filter = tokenContract.filters.Transfer();
const events = await tokenContract.queryFilter(filter);
console.log(events);
const blockNumber = await provider.getBlockNumber();
const block = await provider.getBlock(blockNumber);
console.log(block);