Skip to content

Web Libraries

The ethers.js library is a comprehensive and concise library for engaging with the Ethereum Blockchain and its surrounding ecosystem.

Some of the main features are:

  • Import and export JSON wallets (Geth, Parity and crowdsale)
  • Import and export BIP 39 mnemonic phrases (12 word backup phrases) and HD Wallets
  • Meta-classes create JavaScript objects from any contract ABI, including ABIv2 and Human-Readable ABI Connect to Ethereum nodes over JSON-RPC, INFURA, Etherscan, Alchemy or Metamask

Implementation Example

  1. Package Install
    Terminal window
    npm install ethers@5.7.2
  2. Contract Call
    import { ethers, BigNumber } from 'ethers';
    import { abi } from "./contract";
    import { chains } from "./chains"
    import dotenv from 'dotenv';
    dotenv.config();
    //Select the SKALE chain you want to use
    const selectedChain = chains.nebula;
    const provider = new ethers.providers.JsonRpcProvider(selectedChain.chainInfo.testnet.rpcUrl);
    const pk = process.env.PRIVATE_KEY || "";
    const signer = new ethers.Wallet(pk, provider);
    const contract = new ethers.Contract(selectedChain.chainInfo.testnet.contracts[0].address, abi, signer);
    // Send transaction to smart contract to update message
    async function ContractSendTx() {
    const data = await contract.populateTransaction.mintTest(signer.address);
    data.gasLimit = BigNumber.from(100000);
    data.gasPrice = BigNumber.from(100000);
    data.nonce = await provider.getTransactionCount(signer.address);
    const approveTxSigned = await signer.signTransaction(data);
    const submittedTx = await provider.sendTransaction(approveTxSigned);
    const approveReceipt = await submittedTx.wait();
    console.log(approveReceipt.transactionHash);
    }

Additional EthersV5 Documentation

Click here for the official documentation.