I am having trouble interacting with myetherapi.com using web3.py. I am able to create a few functions that were working, like get_eth_balance()
below. But to send transactions like send_eth()
, I just keep getting this ValueError:
ValueError: {'code': -32601, 'message': '{eth_sendTransaction} Method not found or unavailable', 'data': None}
Any help would be greatly appreciated, what am I missing here?
from web3 import Web3, HTTPProvider
class MyWallet():
def __init__(self, addr=None, key=None):
self.addr = addr
self.key = key
self.w3 = Web3(HTTPProvider('https://api.myetherapi.com/eth'))
def get_eth_balance(self):
return self.w3.eth.getBalance(self.addr)
def send_eth(self, address, amt):
transaction = {
'from': self.addr,
'to': address,
'value': Web3.toWei(amt, 'ether')
}
return self.w3.eth.sendTransaction(transaction)