0

I am getting the error in the title when trying to update the contract with a function I wrote. Any help with this? If I change 'from' to 'to' and use my address it also doesn't work properly. I am using w3.py

store_transaction = Voting_Contract.functions.addPoll("First Test.").buildTransaction(
{
    "gasPrice": w3.eth.gas_price,
    "chainId": chain_id,
    "from": my_address,
    "nonce": nonce + 1,
}  # this is creating a transaction

signed_store_txn = w3.eth.account.sign_transaction(
store_transaction, private_key=private_key
)
# we send the transaction
send_store_tx = w3.eth.send_raw_transaction(signed_store_txn.rawTransaction)
print("Contract Updated.")
# we wait for the transaction to finish
tx_receipt = w3.eth.wait_for_transaction_receipt(send_store_tx) 

1 Answer 1

0

You must first call the contract constructor and then the function you want to call. In your case it will be:

store_transaction = Voting_Contract.constructor().buildTransaction(
{
    "gasPrice": w3.eth.gas_price,
    "chainId": chain_id,
    "from": my_address,
    "nonce": nonce,
} 

signed_store_txn = w3.eth.account.sign_transaction(
   store_transaction, private_key=private_key )

send_store_tx = w3.eth.send_raw_transaction(signed_store_txn.rawTransaction)`

(your function call)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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