Ethers.js 使用
單位 Ether 轉 Wei
ethers.utils.parseUnits("0.11", "ether")單位 Wei 轉 Ether
ethers.utils.formatEther(balance);讀取地址餘額:
const { ethers } = require("ethers");
let provider = new ethers.providers.InfuraProvider('rinkeby');
let address = "0x00....";
provider.getBalance(address).then((balance) => {
let etherString = ethers.utils.formatEther(balance);
console.log("Balance: " + etherString);
});執行合約
讀取合約:
前端使用 sendTransaction 與 signMessage
從後端呼叫 function
Call static
JSON 內有 Bigint 結構轉換
Last updated