Git Product home page Git Product logo

zrc's Introduction

ZRC (Zilliqa Reference Contracts)

Contract standards for the Zilliqa platform

Build Status License: MIT

The Zilliqa Reference Contracts (ZRCs) are the contract standards for the Zilliqa platform.

ZRC Title
ZRC-7 NFT Metadata Standard
ZRC-6 Non-Fungible Token Standard
ZRC-5 Convention for Deposit of ZIL
ZRC-4 Standard for Multisig Wallet
ZRC-3 Standard for Metatransactions
ZRC-2 Standard for Fungible Tokens
ZRC-1 Standard for Non Fungible Tokens (deprecated)

Contributing

  1. Review ZRC-0.
  2. Fork the repository by clicking "Fork" in the top right.
  3. Add your ZRC to your fork of the repository. There is a template ZRC here.
  4. Submit a Pull Request to Zilliqa's ZRC repository.

Your first PR should be a first draft of the final ZRC. An editor will manually review the first PR for a new ZRC and assign it a number before merging it. Make sure you include a discussions-to header with the URL to a discussion forum or open GitHub issue where people can discuss the ZRC as a whole.

If your ZRC requires images, the image files should be included in a subdirectory of the assets folder for that ZRC as follow: assets/zrc-X (for zrc X). When linking to an image in the ZRC, use relative links such as ../assets/zrc-X/image.png.

When you believe your ZRC is ready to progress past the 'Draft' phase, you should go to our Zilliqa Official Discord server and ask to have your issue added to the next community dev call where it can be discussed for inclusion in a future platform upgrade. If the community agrees to include it, the ZRC editors will update the state of your ZRC to 'Approved'.

ZRC Status

  1. Draft - a preliminary version of the ZRC that is not yet ready for submission.
  2. Ready - a preliminary version of the ZRC that is ready for review by a wide audience.
  3. Approved - a finalized version of the ZRC that has been in the 'Ready' state for at least 2 weeks and any technical changes that were requested have been addressed by the author.
  4. Implemented - a finalized version of the ZRC that the Core Devs have decided to implement and release.

Contract Testing

npm test

Runs contract tests using Isolated Server container, Jest, and Scilla JSON Utils

License

This project is open source software licensed as MIT.

zrc's People

Contributors

amritkumar avatar anton-trunov avatar arnavvohra avatar bb111189 avatar csajedi avatar dependabot[bot] avatar edison0xyz avatar frankmeds avatar gb3h avatar greyecologist avatar lukozill avatar metasmile avatar ratulsaha avatar renlulu avatar snowsledge avatar suenchunhui avatar teye avatar thevrintern avatar vaivaswatha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zrc's Issues

Inconsistent behaviors of procedures in ZRC1

There are inconsistent behaviors of some procedures in ZRC1.
e.g.

  • ๐ŸŸข IsTokenOwner throws an error if not a token owner
  • ๐ŸŸข IsMinter throws an error if not a minter
  • ๐Ÿ”ด IsSelf throws an error if self
  • ๐Ÿ”ด IsTokenExists throws an error if the token exists

This inconsistency can be confusing and error-prone.

Therefore the following can be

  • ๐Ÿ”ด IsSelf throws an error if self
  • ๐Ÿ”ด IsTokenExists throws an error if the token exists

changed to

  • ๐ŸŸข IsNotSelf throws an error if self
  • ๐ŸŸข IsTokenNotFound throws an error if the token exists

ZRC#1

Comment tracker for ZRC 1.

Reference contracts naming scheme

As of now the reference-contracts directory looks like this:

.
โ”œโ”€โ”€ FungibleToken-Mintable.scilla
โ”œโ”€โ”€ FungibleToken-Operator.scilla
โ”œโ”€โ”€ FungibleToken.scilla
โ”œโ”€โ”€ MetaFungibleToken.scilla
โ”œโ”€โ”€ multisig_wallet.scilla
โ”œโ”€โ”€ nonfungible-token.scilla
โ”œโ”€โ”€ style-guide.md
โ””โ”€โ”€ zrc6.scilla

and it's not clear what, for instance, nonfungible-token.scilla's ZRC number is.

One possible proposal could be to prepend all the contract names with their ZRC index like so:

.
โ”œโ”€โ”€ zrc2_FungibleToken-Mintable.scilla
โ”œโ”€โ”€ zrc2_FungibleToken-Operator.scilla
โ”œโ”€โ”€ zrc2_FungibleToken.scilla
โ”œโ”€โ”€ zrc3_MetaFungibleToken.scilla
โ”œโ”€โ”€ zrc4_Multisig-Wallet.scilla
โ”œโ”€โ”€ zrc1_NonFungibleToken.scilla
โ”œโ”€โ”€ style-guide.md
โ””โ”€โ”€ zrc6_NonFungibleToken.scilla

Pattern/anti-pattern guide

We could use a guide to patterns/antipatterns in Scilla.

Examples:

  • Don't use ping-pong between contracts. Instead, attempt to complete everything in one contract before invoking transitions on the other contract. If the second contract for some reason discovers a problem, then throw an exception (or otherwise cause an execution error), so that the entire chain of invocations are rolled back.

  • Avoid using the size operation, as it requires reading the entire map from the state. Instead, manually maintain a size counter, and use a dedicated procedure to update the map and the counter together, so that they are always kept in sync.

Transactions keep failing

$ cd example/zrc2
$ node transfer.js 
Your account address is:
0x501A70ffEAA3F31C1caccE3479e74713546BAA44
undefined

Why this undefined?

If I add console.log(JSON.stringify(callTx, null, 4)); after await contract.call(...), I get:

{
    "code": "",
    "data": "{\"_tag\":\"Transfer\",\"params\":[{\"vname\":\"to\",\"type\":\"ByStr20\",\"value\":\"0xBFe2445408C51CD8Ee6727541195b02c891109ee\"},{\"vname\":\"amount\",\"type\":\"Uint128\",\"value\":\"100\"}]}",
    "version": 21823489,
    "toAddr": "0x509aE6e5D91CEE3c6571Dcd04aa08288a29D563A",
    "nonce": 130,
    "pubKey": "03043f88a66a8d79df51c17b7297239b613db510abb04dddc072f0aac5666e716e",
    "amount": "0",
    "signature": "8dc1069bf5b4473ca255f393f026b10c55b705d8fd1859a4149983b4686d078866499a9a43e66df038d2defb35328a1f5eba5da97ac3908fa093ff83c5f50460",
    "gasPrice": "3b9aca00",
    "gasLimit": {
        "low": 10000,
        "high": 0,
        "unsigned": false
    },
    "provider": {
        "middleware": {
            "request": {},
            "response": {}
        },
        "nodeURL": "https://dev-api.zilliqa.com",
        "reqMiddleware": {},
        "resMiddleware": {}
    },
    "status": 3,
    "toDS": false,
    "blockConfirmation": 0,
    "eventEmitter": {
        "handlers": {},
        "emitter": {},
        "promise": {}
    }
}

Does "status": 3 mean "Consensus failure in network"? What is it? Why? How to make it work?

ZRC#2: dummy ADT

Lines 39-41 in the ZRC-2 reference contract (fungible token) look like they should be removed , see

(* Dummy user-defined ADT *)

(* Dummy user-defined ADT *)
type Unit =
| Unit

This ADT Unit is not used anywhere.

ZRC#0

Comment tracker for ZRC#0

ZRC#3

Comment Tracker for ZRC#3

ZRC#3 extends ZRC#2 to enable a more equitable check-teller transaction pattern, as an alternative or supplement to the omnipotent operator.

ZRC contracts must have unique names for callback transitions

For example, the ZRC-1 and ZRC-2 contracts share the same name for a callback, namely TransferSuccessCallBack.

This prevents using both of these ZRCs in one user contract because that forces the user to have two TransferSuccessCallBack transitions with different type signatures.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.