Sending Static Calls to a Smart Contract With Ethers.js | by Jelilat Anofiu | Mar, 2022

Metamask Transaction affirmation screenshot
npm set up --save ethers
Uniswap V3 ABI
  • Create an abi.json file and paste the ABI into it.
  • Subsequent, create a brand new file that’ll be used to make the statical name.
  • Import the ethers library and abi into your code.
const  ethers, suppliers  = require('ethers');require('dotenv').config()const abi = require('./abi.json')
  • Outline the contract deal with, signer, and initialize the contract.
const contractAddress = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"const signer = new ethers.Pockets(   course of.env.PRIVATE_KEY,
);const contract = new ethers.Contract(contractAddress, abi, signer);
  • Outline the transaction variables.
const from = "0x66fe4806cD41BcD308c9d2f6815AEf6b2e38f9a3"const to = "0xC41672E349C3F6dAdf8e4031b6D2d3d09De276f9"const tokenId = 100
const transaction = async () =>    const a = await contract.callStatic.transferFrom(from, to, tokenId)   console.log(a)transaction()
purpose: 'ERC721: switch caller shouldn't be proprietor nor permitted',
methodology: 'transferFrom(deal with,deal with,uint256)',
errorArgs: [ 'ERC721: transfer caller is not owner nor approved' ],
errorName: 'Error',
errorSignature: 'Error(string)',
deal with: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
args: [
knowledge: '0x23b872dd00000000000000000000000066fe4806cd41bcd308c9d2f6815aef6b2e38f9a3000000000000000000000000c41672e349c3f6dadf8e4031b6d2d3d09de276f90000000000000000000000000000000000000000000000000000000000000064',
to: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
from: '0xC41672E349C3F6dAdf8e4031b6D2d3d09De276f9'


More Posts