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


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


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)

Thanks for any hint!

  • 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 Feb 13 '18 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. – MichaelRazum Feb 13 '18 at 20:49
  • I removed the approve but still getting the same message: etherscan.io/tx/… – MichaelRazum Feb 13 '18 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 Feb 13 '18 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. – MichaelRazum Feb 14 '18 at 9:12

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, privacy policy and cookie policy

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