current position:Home>Use Web3 Py failed to call the contract function, but there is no problem using Remix call. What's going on?

Use Web3 Py failed to call the contract function, but there is no problem using Remix call. What's going on?

2022-02-04 00:18:18 Q & A of Denglian community

I use remix Deployed a contract , I am here remix There is no problem calling the functions of the contract , But use web3.py When you adjust the contract function , It doesn't work , Always prompt :execution reverted: failed to execute message. What's going on here ?python Code :

deadline = int(time.time()) + 300 func = self.arb_contract.functions.swap(address,deadline) tx = {                'from': address,                'value': self.w3.toWei(value, 'ether'),                'gas': 250000,                'gasPrice': self.w3.eth.gas_price,                'nonce': self.w3.eth.getTransactionCount(address)   }  transaction = func.buildTransaction(tx)  signed_tx = self.w3.eth.account.sign_transaction(transaction, private_key)  tx_hash = self.w3.eth.sendRawTransaction(signed_tx.rawTransaction).hex()  self.w3.eth.waitForTransactionReceipt(tx_hash)

stay remix Result of call up :image.png

Use python The result of the call :image.png






Other answers 1:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202040018155987.html

Random recommended