繁体   English   中英

以太坊python mytherwallet

[英]Ethereum python mytherwallet

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)

发送以太坊的类。 send_eth()返回txID,但不要汇款。 我已经等了3个小时。 交易不发送。 请帮忙

你的nonce太高了。 帐户的nonce从0开始,并且每次进行交易时都会增加。 您可以通过调用eth_getTransactionCount获得正确的当前nonce eth_getTransactionCount

nonce太高意味着无法进行交易。 它会在事务池中徘徊一会儿,直到nonce变为有效或经过了太多时间才被丢弃。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM