0

I'm currently use this package to generate new transaction in ETH:

https://github.com/kornrunner/php-ethereum-offline-raw-tx

Now I want to generate a transaction for an ERC20 token like Tether. As I know when we want to create an eth transaction we have to set all of these items :

nonce' => $this->nonce,
            'gasPrice' => $this->gasPrice,
            'gasLimit' => $this->gasLimit,
            'to' => $this->to,
            'value' => $this->value,
            'data' => $this->data,
            'v' => $this->v,
            'r' => $this->r,
            's' => $this->s,

But I don't have any idea about tokens, are they same as ETH transaction? How and where we defined this transaction is about token and which token?

2 Answers 2

1

In general, ERC20 token transaction is completely different than ETH transaction. If transaction occurs between two contracts, for a ETH transaction the receipt contract must have fallback function in its code. Also, the sender must have fallback function in its contract code. Whereas, an ERC20 token transaction does not need any fallback function neither in sender's contract nor in receipt's contract. ERC20 token is a contract that determines how much an address has token, that token defined in the same contract. Sender's contract tells ERC20 token contract to decrease its balance with a value and increase the receipt's balance with the same value. In final, i suggest you read this to more information.

And in answer to your second question. Ledger does not show you how much you have that token, to eliminate that you need to connect to the token contract and get your balance, and you can't see a transaction is an ERC20 token but can see it is not an ether transaction. But,a wallet ,like Metamask, can show you all mentioned.

Good Luck.

0

I found this article for ETH transfer: https://goethereumbook.org/en/transfer-eth/

And this one for Token transfer : https://goethereumbook.org/en/transfer-tokens/

Also for PHP developers there is this package:

https://github.com/kornrunner/php-ethereum-token

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.