-
I deployed my Fund_me smart contract on Kovan testnet and I tried to call the withdraw function on it using web3, but I'm getting the error ValueError: {'code': -32016, 'data': 'Reverted', 'message': 'The execution failed due to an exception.'}. How can I troubleshoot this or get a more detailed error of what's wrong? Here's the contract withdraw method: modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function withdraw() public payable onlyOwner {
msg.sender.transfer(address(this).balance);
for (
uint256 funderIndex = 0;
funderIndex < funders.length;
funderIndex++
) {
address funder = funders[funderIndex];
addressToAmountFunded[funder] = 0;
}
funders = new address[](0);
} Here's the web3 code to invoke the withdraw method on the contract: web3 = Web3(
Web3.HTTPProvider("https://kovan.infura.io/v3/a7cfd54a6f5147449c622316ea15a4ba")
)
abi = '[{"inputs":[{"internalType":"address","name":"_priceFeed","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"addressToAmountFunded","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fund_Catherine","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"funders","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"name":"getConversionRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getEntranceFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeed","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"}]'
addr = "0xAAa9F30a71456aFB436dDF49BaA12952F5116017"
modelcontract = web3.eth.contract(address=addr, abi=abi)
tx = modelcontract.functions.withdraw().buildTransaction()
tx.update({"from": str(account)})
tx.update({"to": addr})
tx.update({"gas": 21000})
tx.update({"gasPrice": 2})
nonce = web3.eth.get_transaction_count(str(account))
print(nonce)
tx.update({"nonce": nonce})
signed_message = web3.eth.account.sign_message(
tx, private_key=config["wallets"]["from_key"]
tx_hash = web3.eth.send_raw_transaction(signed_message.rawTransaction)
tx_receipt = web3.eth.wait_for_transaction_receipt(tx_hash, 180) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 12 replies
-
Hey @ptn77 I hope you're deploying the right contract, try changing this |
Beta Was this translation helpful? Give feedback.
-
Hello @ptn77 |
Beta Was this translation helpful? Give feedback.
-
I have many functions 😆
…On Sun, Apr 3, 2022, 11:27 PM Vasiliy Gualoto ***@***.***> wrote:
Hello @ptn77 <https://github.com/ptn77>
Why your Abi is that big?
—
Reply to this email directly, view it on GitHub
<#1367 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB63TJMEPS2T6HXMJNMFR73VDJ4TDANCNFSM5SOF7OVA>
.
You are receiving this because you were mentioned.Message ID:
<smartcontractkit/full-blockchain-solidity-course-py/repo-discussions/1367/comments/2497613
@github.com>
|
Beta Was this translation helpful? Give feedback.
Hello @ptn77
Why your Abi is that big?