gno icon indicating copy to clipboard operation
gno copied to clipboard

feat(gnovm/tm2): add ZeroAddress constant

Open thinhnx-var opened this issue 8 months ago • 5 comments

Contributors' checklist...
  • [ ] Added new tests, or not needed, or not feasible
  • [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • [ ] Updated the official documentation or not needed
  • [ ] No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • [ ] Added references to related issues and PRs
  • [ ] Provided any useful hints for running manual tests
  • [ ] Added new benchmarks to generated graphs, if any. More info here.

After discussion in #2316, this PR does:

  • add std.ZeroAddress() with address g100000000000000000000000000000000dnmcnx in tm2.
  • Logic: add coins to zeroAddress when user burn coin with SDKBanker.RemoveCoin()
  • add a ZeroAccount with account_number = 0 when initializing the chain
  • add std.ZeroAddress() in gnovm/std in oder to help realm can burn coins to this address.

There are 2 main usecase of this adding that I think about:

  • With native, user can burn coin by sending it to ZeroAddress
❯ gnokey maketx send -gas-fee="1000ugnot" -gas-wanted="50000" -send="1000ugnot" -to g100000000000000000000000000000000dnmcnx -broadcast testKey
  • With token like grc20, user can burn coin by calling transfer to ZeroAddress:
❯ gnokey maketx call -pkgpath "gno.land/r/thinhnx/foo20" -func "Transfer" -args "g100000000000000000000000000000000dnmcnx" -args "5000000000" -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast testKey

Status:

In this approach, I think we should deduct the total supply coin / token in chain, but it is neither implemented in native coin, nor grc20 standard. This may be relate to this @leohhhn 's PR #2314.

Demo:

Native coin Pasted Graphic

grc20 token - I changed admin address to mine when testing Pasted Graphic 1

This is my first implementation about zero address in gno ecosystem. I really want to know if there is any idea to make this better!

thinhnx-var avatar Jun 20 '24 11:06 thinhnx-var