class MyEtherApi():
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, gas):
tx = Transaction(
to=address,
value=Web3.toWei(amt, 'ether'),
nonce=int(time()),
gasprice=self.w3.eth.gasPrice,
startgas=int(gas),
data=b'',
)
tx.sign(self.key)
raw_tx = rlp.encode(tx)
signed = self.w3.toHex(raw_tx)
return self.w3.eth.sendRawTransaction(signed)
Class for send ethereum. send_eth() return txID, but dont send money. I have wait more 3 hours. Transaction doesnt send. Please help
Your nonce
is going to be way too high. The nonce
for an account starts at 0 and increases each time the account makes a transaction. You can get the correct current nonce
for an account by calling eth_getTransactionCount
.
A nonce
that's too high means the transaction can't be mined. It will hang around in the transaction pool for a while until the nonce
becomes valid or too much time passes and it's dropped.