0

I'm using this e-book to learn about using go-ethereum, but it's pretty outdated. I'm on the part about transferring tokens and I'm getting an invalid opcode when estimating gas. I have a private key to a wallet that has a few thousand testing tokens on Rinkeby, and I'm trying to send it to another wallet as the guide shows. Pretty much everything is the same in my code as in the guide save for the private key and addresses. The output looks like this:

0x4b40e901 (method ID)
0x000000000000000000000000546e6ad2e7aa8c047ae5d022d183c5918d7b158b (padded address)
0x00000000000000000000000000000000000000000000000011200c7644d4fff2 (padded amount)

2021/08/19 16:17:34 invalid opcode: opcode 0x4b not defined (when doing EstimateGas())

I'm guessing this might be happening due to the guide being outdated in terms of how contracts are handled, maybe the hashing method has changed? I am very interested also if anyone has a more updated guide for go-ethereum that covers sending ERC-20 tokens. I'm working on the Rinkeby test net.

3
  • Nothing has changed for transferring tokens. What does your code look like?
    – Ismael
    Aug 21 '21 at 23:44
  • My code looks the same as the book's (see here), only with different private/public keys of course. I am curious as to what you mean by nothing has changed, when this code has types.NewTransaction() in it, which is depreciated.
    – ckrug
    Aug 22 '21 at 18:20
  • I haven't used go to interact wit the blockchain so perhaps that changed, ethereum keeps working the same. An odd thing about the error message is that 0x4b was never a valid opcode. It is the first byte from the data field so it appears the code is executing it instead of the contract.
    – Ismael
    Aug 22 '21 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.