0

Is there any way that we can add hex data in ERC20 transaction? Let s say we want to keep track of why we send the token and other detailed information. How can we achieve that?

  • 1
    You can implement your ERC20 however way you like, so long as it conforms to the ERC20 standard (i.e., implements the ERC20 standard interface). You can add as much info as you'd like, within the practical limitations of the underlying infrastructure (e.g., 256-bit integers, maximum 3 indexed parameters per event, etc). – goodvibration Sep 3 at 17:16
1

Yes this is possible.

You have to modify the transfer function of your token contract.

Doing this would be a bit complicated. Keep in mind you need to pay attention to still comply with the EIP20 Standard.

I would go about this by creating a new function with the same parameters as transfer and you additional paramets, save your information and then call transfer function with the to and value parameter. Therefore, the Transfer event gets emitted and you are still compliant to the standard.

  • 1
    Two comments: 1) It's not Transfer function but with a lowercase so it's not confused with the event. 2) I'm not sure what you mean with "shouldn't be that big of a deal". How do you propose to modify the function so that it takes extra data (the reason) while complying with EIP20? – Lauri Peltonen Sep 3 at 19:06
  • Sorry for the bad explanation. Yes that was a typo. I updated my answer to meet my great quality standards. – Niklas Feurstein Sep 3 at 19:11
  • Thanks for the edit. The way you propose is possible in theory but, in my opinion, unrealistic. The extra data would have to be stored in the state and then in some fashion added to the real transfer function - it would be tricky to keep track of which data belongs to which transfer, for example. – Lauri Peltonen Sep 3 at 19:15
  • I don't think this is feasible because exchanges and wallets would disregard an extra function and adding a parameter to transfer changes its function signature. – Rob Hitchens - B9lab Sep 4 at 5:50
1

See my comment about why I don't think this is feasible.

As a general heuristic, let the currency be a currency - a simple unit of account, a medium of exchange and possibly a store of value. A dollar doesn't know why it moves but the machinery that accepts it usually does. Token contracts spell out the supply and look after basic accounting.

A line-of-business contract can present any set of functions that collect required information, possibly coordinated with payment processes. This is usually the best region to be thinking about implementing business rules. Not as properties of the currency but as terms of service, delivery and usually records.

A token contract can tell you how much money each participant has. A line-of-business contract might be able to explain why.

Hope it helps.

1

As I mentioned in comments to the other answer: in theory it is possible to add such functionality (by for example calling another function before the real transfer) but, in my opinion, in reality it's not feasible. Mostly because I doubt any third party wants to implement such extra features at their end. The point of standards is that they are standard and one implementation covers all contracts which follow the standard. Modifications which are outside the standard mean extra work for anyone who uses the token just for this one token. Furthermore, it would be tricky to keep tract of which extra data belongs to which transfer if the extra data is stored in a separate function call.

There may be other standards (derived from EIP20) out there which might do what you want, but they are not widely accepted in any case. Still, a bad standard would be better than no standard.

One option would be to simply forget about standards. So just write your token to be whatever you need it to be. It most likely won't be accepted in any exchanges and no third party wants to implement it but depending on your needs this might not be a problem for you.

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.