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)

1 Answer 1


eth_sendTransaction is not on the list of Allowed Methods shown at http://www.myetherapi.com/

eth_sendTransaction assumes that the node has access to the private key of the account that you're sending from, but myetherapi does not. So you'll have to sign locally and use sendRawTransaction. The most convenient way to do that (in Python) is with the w3.eth.account section of Web3.py, as of version 4.

You can use w3.eth.account.signTransaction() to sign locally before sending.

>>> transaction = {
        'to': '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
        'value': 1000000000,
        'gas': 2000000,
        'gasPrice': 234567897654321,
        'nonce': 0,
        'chainId': 1
>>> key = '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318'
>>> signed = w3.eth.account.signTransaction(transaction, key)

>>> signed.rawTransaction
>>> signed.hash
>>> signed.r
>>> signed.s
>>> signed.v

# When you run sendRawTransaction, you get back the hash of the transaction:
>>> w3.eth.sendRawTransaction(signed.rawTransaction)  


  • How/where could I obtain the key? Is key stands for private key? @carver
    – alper
    Apr 4, 2018 at 10:46
  • 1
    Yes, it's the private key for the account you want to send the transaction from
    – carver
    Apr 4, 2018 at 15:46

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.