My code:
from ethereum import transactions
from ethereum import utils
import requests
import json
def json_rpc(url, method, params, id):
headers = {'content-type': 'application/json'}
payload = {
"method": method,
"params": params,
"jsonrpc": "2.0",
"id": id,
}
try:
response = requests.post(url, data=json.dumps(payload), headers=headers)
if response.status_code == 200:
response = response.json()
return response
except Exception as e:
print(e)
return(e)
tx = transactions.Transaction(nonce=8, gasprice=5000000000,
startgas=45000, to=contract_address, value=0,
data="0x957a0e210000000000000000000000000000000000000000000000000000000000000037").sign(private_key)
tx = tx.to_dict()
print(tx)
Output:
{'nonce': 8, 'gasprice': 5000000000, 'startgas': 45000, 'to': '0x4d21f3618bc4c50475d4b30993d80cffe78b3650', 'value': 0, 'data': '0x3078393537613065323130303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303337', 'v': 27, 'r': 104827557381449577376519412355902868429829733841563149787296871707166833642558, 's': 29002009444020075645692529433910482836532514345220494513395292371410739844134, 'sender': '0xd1bb5d5c362bb4faf25c23b3c7c42c8ea30dc10d', 'hash': '0x20d1a85cf3e6f4d11655c9ba0f09602ea4881b6abcc192581fca18b24634cd2c'}
Question:
The geth json RPC api has a method called "eth_sendRawTransaction" which requires one param. How do I encode the above output to send correctly using json rpc to my geth node? Which value am I supposed to send?