logo

ethers.js

To interact with Darwinia nodes, you can use ethers.js library.
Getting Started
Documentation for ethers, a complete, tiny and simple Ethereum library.
Getting Started

Connecting with MetaMask

typescript
import { ethers } from "ethers"; // A Web3Provider wraps a standard Web3 provider, which is // what MetaMask injects as window.ethereum into each page const provider = new ethers.providers.Web3Provider(window.ethereum) // MetaMask requires requesting permission to connect users accounts await provider.send("eth_requestAccounts", []); // The MetaMask plugin also allows signing transactions to // send ether and pay to change state within the blockchain. // For this, you need the account signer... const signer = provider.getSigner()

Connecting through RPC

typescript
import { ethers } from "ethers"; // const provider = new ethers.providers.JsonRpcProvider("https://pangolin-rpc.darwinia.network"); // const provider = new ethers.providers.JsonRpcProvider("https://pangoro-rpc.darwinia.network"); // const provider = new ethers.providers.JsonRpcProvider("https://crab-rpc.darwinia.network"); const provider = new ethers.providers.JsonRpcProvider("https://rpc.darwinia.network"); // The provider also allows signing transactions to // send ether and pay to change state within the blockchain. // For this, we need the account signer... const signer = provider.getSigner()

Powered by Notaku