4

I have two transaction, the first from MetaMask (everything is fine)

https://etherscan.io/tx/0x1ab684f4875f8cc28043d9f3c3536a5e4f8a565cadda7a29bc6a96db5f1d0f8f

the second using web3.py (it seems to be identical but fails)

https://etherscan.io/tx/0xc019007895cb7340f65c3bd80df5561c1b1a98d8eac6dc2babf776ab000de067

Here is my part of the code: (I hope it is clear what is going on - it is copied from a class)

# same as in the working one
abidata = '0x338b5dea000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f49800000000000000000000000000000000000000000000000000002d79883d2000'
trans = {
                        'to': self.address,
                        'from': self.ethapi.address,
                        'data': abidata,
                        'value': 0,
                        'chainId': 1}
# transaction gas data [pseudocode]
trans_new = trans.copy()
nonce = w3.eth.getTransactionCount(self.address)
gas_price = self.get_gas_price()
gas_price_wei = self.w3.toWei(gas_price,"Gwei")
trans_new["gas"] = 250000
trans_new["nonce"] = nonce
trans_new["gasPrice"] = gas_price_wei
signed_transaction = account.signTransaction(trans)
w3.eth.sendRawTransaction(signed_transaction.rawTransaction)

Thanks for any hint!

6
  • 1
    From the vmtrace it is failing in the token contract. Did you call approve() to allow ED to make a transfer from your address?
    – Ismael
    Commented Feb 13, 2018 at 20:13
  • Actually not. I approved to radarrelay.com. Was playing around. Maybe that is the reason. It's just strange that it seems to work with MetaMask, so I guess there is some kind of difference in both transactions. Commented Feb 13, 2018 at 20:49
  • I removed the approve but still getting the same message: etherscan.io/tx/… Commented Feb 13, 2018 at 21:14
  • You need to send ZrxToken an approval for EtherDelta to make a transfer from your account. If you want to make a deposit to EtherDelta you need to make two transactions 1) ZrxToken.approve(EtherDelta.address, amount, { from: "YourAccount" }), 2) EtherDelta.depositToken(ZrxToken.address, amount, { from: "YourAccount" }).
    – Ismael
    Commented Feb 13, 2018 at 22:56
  • Thanks a lot! I will try it out and post! Its just strange that with MetaMask I see only one transaction that was send from my account. Commented Feb 14, 2018 at 9:12

1 Answer 1

2

As suggested by Ismael in the comments above, my mistake was that MetaMask did two transactions. So the first one was an approval that was missing.

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.