3

Is it possible to generate a raw transaction using pyethereum library taking inputs wallet json, password, along with transaction parameters?

My attempt below, I get the hex, when inputting hex into MyEtherWallet send from offline, it recognizes the amount and target address, but then gives 'Invalid format'. Hoping for a suggestion to debug this. Thanks!

from ethereum import transactions, utils
from ethereum.tools.keys import decode_keystore_json
import rlp,json

def genTransactionHex(target,nonce,wallet_json,amount = 0, gasprice = 24000000000, startgas=21000):

    priv_key = decode_keystore_json(wallet_json, raw_input("decode wallet:"))

    #[nonce, gasprice, startgas, to, value, data, v, r, s]
    tx = transactions.Transaction(nonce, gasprice, startgas, target, amount, "").sign(priv_key)
    return rlp.encode(tx).encode('hex')

with open('wallet.json') as wallet_data:
    wallet = json.load(wallet_data)

target = '0x67e5d173BE803Ca97687498CD3F892BFaB54d12C'
res=genTransactionHex(target, 0, wallet, 10000000000)

[EDIT] here is an example hex: [removed]

[EDIT2] Tried this on etherscan , and it worked! Not sure why it wasn't going through on MyEtherWallet.

1 Answer 1

1

Can you paste an example of the transaction hex that you are trying to put into MyEtherWallet? That python should work fine as is, so I'm wondering what could be wrong...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.