Hi, i try connect to infura with my code python but i recive this message: invalid sender. Somebody know why?
def enviarBlockchain(datosfinal,viaje):
url = “https://rinkeby.infura.io/v3/9e71d2450c4b42ea9dd3f6d40f239ffe”
w3 = Web3(Web3.HTTPProvider(url))
w3.middleware_onion.inject(geth_poa_middleware, layer=0)
abigail = [
{
"anonymous": "false",
"inputs": [
{
"indexed": "false",
"internalType": "uint256",
"name": "viajeId",
"type": "uint256"
},
{
"indexed": "false",
"internalType": "string",
"name": "ciaId",
"type": "string"
},
{
"indexed": "false",
"internalType": "address",
"name": "userAddress",
"type": "address"
},
{
"indexed": "false",
"internalType": "bool",
"name": "eco",
"type": "bool"
},
{
"indexed": "false",
"internalType": "string",
"name": "facturaId",
"type": "string"
},
{
"indexed": "false",
"internalType": "uint256",
"name": "km",
"type": "uint256"
},
{
"indexed": "false",
"internalType": "string",
"name": "hashProveedor",
"type": "string"
},
{
"indexed": "false",
"internalType": "string",
"name": "huellaCO2",
"type": "string"
}
],
"name": "nuevoViaje",
"type": "event"
},
{
"constant": "false",
"inputs": [
{
"internalType": "string",
"name": "ciaId",
"type": "string"
},
{
"internalType": "address",
"name": "userAddress",
"type": "address"
},
{
"internalType": "bool",
"name": "eco",
"type": "bool"
},
{
"internalType": "string",
"name": "facturaId",
"type": "string"
},
{
"internalType": "uint32",
"name": "km",
"type": "uint32"
},
{
"internalType": "string",
"name": "hashProveedor",
"type": "string"
},
{
"internalType": "string",
"name": "huellaCO2",
"type": "string"
}
],
"name": "registrarViaje",
"outputs": [],
"payable": "false",
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": "false",
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "viajes",
"outputs": [
{
"internalType": "string",
"name": "ciaId",
"type": "string"
},
{
"internalType": "address",
"name": "userAddress",
"type": "address"
},
{
"internalType": "bool",
"name": "eco",
"type": "bool"
},
{
"internalType": "string",
"name": "facturaId",
"type": "string"
},
{
"internalType": "uint32",
"name": "km",
"type": "uint32"
},
{
"internalType": "string",
"name": "hashProveedor",
"type": "string"
},
{
"internalType": "string",
"name": "huellaCO2",
"type": "string"
}
],
"payable": "false",
"stateMutability": "view",
"type": "function"
}
]
w3.isConnected()
contractDeployed = w3.eth.contract(abi=abigail,address=“0xaC9A998A3E6F91953e64ED32cD64b9b4B0C68937”)
w3.eth.defaultAccount = “0xcf9833c6b3DBb19F16De86107D8319156e602614”
#nonce = w3.eth.getTransactionCount(‘0xcf9833c6b3DBb19F16De86107D8319156e602614’)
Key = “1e0936afaeaafe8afa0016bf47aa8d6d2e6a27fd5ffe05039dcac42707d9e33d”
print(“Llamada metodo w3*****”)
tx_hash = contractDeployed.functions.registrarViaje(“Atos”,“0xcf9833c6b3DBb19F16De86107D8319156e602614”,True,str(datosfinal[‘viaje’][‘receipt’][‘idreceipt’]),int(datosfinal[‘viaje’][‘receipt’][‘distance’]),‘Nestor’,‘1’).buildTransaction({‘chainId’: 1,‘gas’: 70000,‘gasPrice’: w3.toWei(‘1’, ‘gwei’),‘nonce’: 1,})
print(“Llamada Transaction w3*****”)
enviar_transaction = w3.eth.account.signTransaction(tx_hash, private_key=Key)
w3.eth.sendRawTransaction(enviar_transaction.rawTransaction)
#0xF0F6c37E786e234696979a4af025F24917aF27A6
#str(datosfinal[‘viaje’][‘usuarioatos’])
block=w3.eth.getBlock(‘latest’)
tx_json=w3.toJSON(block)
tx_string = json.loads(tx_json)
txhashdata=tx_string[‘transactions’][0]
#guardarRideTxdata(txhashdata,viaje)