0

I am trying to send data to the contract, but I am getting the following error: The method eth_sendTransaction does not exist/is not available

This is the code:

from web3 import Web3

web3 = Web3(Web3.HTTPProvider("https://rinkeby.infura.io/v3/9fe6f0a016494dfeb4cecd7d1c98431a"))

from web3.middleware import geth_poa_middleware

web3.middleware_onion.inject(geth_poa_middleware, layer=0)

print(web3.eth.blockNumber)

x = web3.isAddress('0xacb0ceacb13e786644f0ab21aa044032ae925874')
print(x)

abi = '''
   ...
      '''

address = Web3.toChecksumAddress('0xacb0ceacb13e786644f0ab21aa044032ae925874')

lucas = '0x690809206b73994282910F1740a729a89aF4beCa'

myContract = web3.eth.contract(address=address, abi=abi)
key = myContract.functions.storeData([1,4]).transact({'from' : lucas})

print(key)

addedData = myContract.functions.getData(key).call()
print(addedData)

The above code can connect to the network rinkeby normally, but cannot perform the transaction. The storeData method takes an array and returns an uint which is key and is working normally in Remix.

I'm using Metamask.

0
key = myContract.functions.storeData([1,4]).buildTransaction({'nonce': web3.eth.getTransactionCount(address)})

signed_tx = web3.eth.account.signTransaction(key, private_key='...')

web3.eth.sendRawTransaction(signed_tx.rawTransaction)
| improve this answer | |

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.