ZRC | Title | Status | Type | Author | Created (yyyy-mm-dd) | Updated (yyyy-mm-dd) |
---|---|---|---|---|---|---|
5 | Convention for Deposit of ZIL | Implemented | Standard | Jun Hao Tan [email protected] | 2020-06-25 | 2021-11-12 |
ZIL is the native token for Zilliqa blockchain. One can store ZIL inside any Zilliqa address, including smart contract address.
ZRC-5 defines a convention for an interface that a smart contract should implement should it decide to accept ZIL.
For a smart contract to accept incoming ZIL, it needs to do so explicitly using the accept
statement. As such, any transition that does not have the accept
statement will not be able to accept any incoming ZIL transfer.
However, there is currently no naming convention for transitions that can accept ZIL. As a result, cryptocurrency exchanges or cryptocurrency wallet providers do not know which _tag
to set, should they wish to transfer ZIL to a contract address.
By having a naming convention for transitions that can accept ZIL, one can easily transfer ZIL to a contract that follows this convention, thereby improving composability.
The deposit of ZIL specification describes:
- the naming convention of the transition
- mandatory instruction in the transition
For a contract that wishes to conditionally or unconditionally accept ZIL, it should implement a transition named AddFunds
that does not take any parameters.
Within the AddFunds
transition, there should be an accept
instruction.
Smart contract developers are free to introduce any programmatic logic to conditionally accept ZIL in AddFunds
transition. Smart contract developers can also use accept
instruction in other transitions, however, such transitions may reduce composability of the smart contract.
This is a sample implementation of AddFunds
transition that unconditionally accepts ZIL.
transition AddFunds ()
accept
end
To test the reference contract, simply go to the example/zrc4
folder and run node add_funds.js
.
Copyright and related rights waived via CC0.