I have this code in python for Ethereum transaction but the transaction is not happening. I have just kept waiting but the transaction does not happen.
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)