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

Metamask Transaction confirmation screenshot
npm install --save ethers
Uniswap V3 ABI
  • Create an abi.json file and paste the ABI into it.
  • Next, create a new file that’ll be used to make the statical call.
  • Import the ethers library and abi into your code.
const { ethers, providers } = require('ethers');require('dotenv').config()const abi = require('./abi.json')
  • Define the contract address, signer, and initialize the contract.
const contractAddress = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"const signer = new ethers.Wallet(   process.env.PRIVATE_KEY,
);const contract = new ethers.Contract(contractAddress, abi, signer);
  • Define 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()
reason: 'ERC721: transfer caller is not owner nor approved',
method: 'transferFrom(address,address,uint256)',
errorArgs: [ 'ERC721: transfer caller is not owner nor approved' ],
errorName: 'Error',
errorSignature: 'Error(string)',
address: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
args: [
transaction: {
data: '0x23b872dd00000000000000000000000066fe4806cd41bcd308c9d2f6815aef6b2e38f9a3000000000000000000000000c41672e349c3f6dadf8e4031b6d2d3d09de276f90000000000000000000000000000000000000000000000000000000000000064',
to: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
from: '0xC41672E349C3F6dAdf8e4031b6D2d3d09De276f9'

Leave a Comment