0

i want to send money to a function but get this error. i using ethers.js

script:

**const {ethers} = require('hardhat');
const abi = require('../data/abi/test.json')
const provider = new ethers.Wallet(   
    "7c4439d4b2367bf58f612c3178b75bbd23a0ad7819dc4f9c1e10222f28e12280",
    ethers.getDefaultProvider("https://eth-rinkeby.alchemyapi.io/v2/LotkPgb_JVDypKN906IO0mkqaI5jG9GA"));                 
    
const contractAddress = '0x3baec270973DDB17A46315a9E8348b391afa8041'
const contract = new ethers.Contract(contractAddress ,abi ,provider )
  
async function wallet() {
 
   
    const options = await provider.sendTransaction({
         value: ethers.utils.parseEther("0.11"),
        gasLimit: 2100000,
      gasPrice: 800000000
    })
       
                                    
    const callFunction = await contract.sendMoney(options)
    console.log('tx is:',callFunction)
    const balance = await contract.getBalance()
    console.log("Balance:",(await ethers.utils.formatEther(balance)))
}
wallet()
    .then(() => process.exit(0))
    .catch((error) => {
      console.error(error);
      process.exit(1);
  });**

full error:

Error: cannot override "chainId","data","hash","v","r","s","confirmations","wait" (operation="overrides", overrides=["chainId","data","hash","v","r","s","confirmations","wait"], code=UNSUPPORTED_OPERATION, version=contracts/5.6.0)

1 Answer 1

0

Watch out, never publish online your private key or your node API key.

I checked your contract on rinkeby but it's not verified, so I can't tell what input data is the contract accepting.

But I think you will find a solution to your issue by just looking at an example like this one:

https://github.com/ethers-io/ethers.js/issues/461#issuecomment-474470663

I would change the options const to:

const options = {
       value:ethers.utils.parseEther("0.11"),
       gasLimit: 2100000,
       gasPrice: ethers.utils.formatUnits(800000000, "gwei")
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.