Giter Site home page Giter Site logo

zns-lgc's Introduction

Zer0 Name Service Contracts

This repository contains the smart contracts for the Zer0 Naming Service (ZNS) from the Zer0 Network.

Architecture and Documentation

Check out the docs folder for more documentation such as architecture.

Building and Development

Follow this guide to learn how to get started with building and developing locally.

This guide will assume you are using Visual Studio Code as an IDE, however you can use whatever IDE you would like.

Required Tools

This project requires yarn to be installed on your system, as well as node.js. Please ensure those are installed on your system before continuing.

Getting Started

In the command line terminal, run the following:

yarn

This will:

  • Install required node packages (this may take awhile)
  • Compile the smart contracts
  • Generate typechain helper types

This step should complete without any errors. If you encounter errors there may be something wrong with your node or yarn installation, ensure you have node version 14 or higher.

If you are still encountering errors please file a GitHub issue with as much detail as possible.

Running Tests

To run the tests for the smart contracts simply run

yarn test

You can check test coverage by running

yarn coverage

You may get a warning about contract code size exceeding 24576 bytes, you can ignore this.

Compiling Contracts

If you ever need to recompile the smart contracts you can run

yarn compile

To recompile the smart contracts.

Running yarn compile will also re-generate the typechain helpers

In some cases you may need to clean previously built artifacts, if you run into errors you can try running yarn build which will clean and re-compile the smart contracts

Linting

You can lint any Solidity and TypeScript files in the project by running:

yarn lint

Many linting issues can be solved automatically by running:

yarn fix

Ensure you run both yarn fix and yarn lint before creating a pull request.

You may get some line-ending errors, this project expects that line-endings are LF and not CRLF.

Deploying

Deployment is done in multiple steps which are to be performed in order.

Requirements

Before you can deploy you must choose the wallet to deploy from. This can be done using a mnemonic phrase that is set in a .env file.

Create a .env file with the contents:

TESTNET_MNEMONIC=<insert your mnemonic here for testnet deployments>
MAINNET_MNEMONIC=<insert your mnemonic here for mainnet deployments>

If you are deploying to kovan, ropsten, or rinkeby, set the TESTNET_MNEMONIC variable.

If you are deploying to mainnet set the MAINNET_MNEMONIC variable.

Do not under any circumstance commit your .env file to source control

Some additional recommendations:

  • Delete your .env file after you finish deploying contracts
  • Never use the same mnemonic for testnets and mainnet
  • Never use your personal wallet or mnemonic
  • Always use a different mnemonic for each new mainnet deployment

Deploy Registrar

The Registrar can must be deployed by running the command:

yarn hardhat run .\scripts\deploy-registrar.ts --network <network>

Replace <network> with mainnet, kovan, ropsten, or rinkeby.

This will deploy the Registrar contract using an OpenZeppelin upgradeability proxy.

You may notice a deployments folder being created, if you inspect the ./deployments/<network>.json file you will find the address of the deployed Registrar under (registrar.address)

It is recommended you commit and push any changes to ./deployments/<network>.json file for historical tracking of deployed instances

Deploy Basic Controller

The Basic Controller can must be deployed by running the command:

The Registrar must already be deployed to run this command.

yarn hardhat run .\scripts\deploy-basic-controller.ts --network <network>

This will deploy the BasicController contract using an OpenZeppelin upgradeability proxy.

The ./deployments/<network>.json file will be updated and you will find the address of the deployed Basic Controller under (basicController.address)

Add the controller to the Registrar

To add the controller to the registrar, thus making it functional, you must run the command:

The Registrar and Basic Controller must already be deployed to run this command.

yarn hardhat run .\scripts\add-controller.ts --network <network>

Once this command has finished running the controller will be able to register new domains with the registrar.

Scripts to help with testing

Testing on Kovan before a mainnet deployment is highly recommended.

Kovan ether can be gained either through the Kovan Faucet or by requesting some from the Kovan Forums.

Send Kovan Eth to accounts

You can send Kovan ether from a wallets account[0] to account[n] (where n is 1-6) by running the command:

You will need ~10 Kovan Eth in account[0] to run this.
If you don't have that much, you can change the script manually

yarn hardhat run .\scripts\send-eth.ts --network <network>

This is merely a helper script, you don't need to run this and it can always be done manually

Simulate usage

You can simulate usage of a Kovan deployed Registrar by running:

yarn hardhat run .\scripts\simulate.ts --network <network>

This will:

  • Create domains
  • Create subdomains
  • Transfer domains and subdomains to different users
  • Set metadata on a domain
  • Lock metadata on a domain
  • Unlock metadata on a domain
  • Set royalty amount on a domain

It will use the first 7 accounts on a mnemonic wallet.

zns-lgc's People

Contributors

remscar avatar stan36 avatar jamesearle avatar xiphiness avatar deep-quality-dev avatar mattcharles avatar whytecrowe avatar jtulloch avatar benefacto avatar real-n3o avatar

Watchers

 avatar

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.