GithubHelp home page GithubHelp logo

dapp-templates's Introduction

DappTools Template

Template repository for getting started quickly with DappTools

Github Actions

Building and testing

git clone https://github.com/gakonst/dapptools-template
cd dapptools-template
make # This installs the project's dependencies.
make test

Deploying

Contracts can be deployed via the make deploy command. Addresses are automatically written in a name-address json file stored under out/addresses.json. Additionally, you can specify a specific network with make deploy-rinkeby or make deploy-mainnet. You can choose which contract you want to deploy, by adding it as a variable, like so:

make deploy-rinkeby CONTRACT=Greeter 

We recommend testing your deployments and provide an example under scripts/test-deploy.sh which will launch a local testnet, deploy the contracts, and do some sanity checks.

Environment variables under the .env file are automatically loaded (see .env.example). Be careful of the precedence in which env vars are read.

We assume ETH_FROM is an address you own and is part of your keystore. If not, use ethsign import to import your private key.

See the Makefile for more context on how this works under the hood

We use Alchemy as a remote node provider for the Mainnet & Rinkeby network deployments. You must have set your API key as the ALCHEMY_API_KEY enviroment variable in order to deploy to these networks

Mainnet

ETH_FROM=0x3538b6eF447f244268BCb2A0E1796fEE7c45002D make deploy-mainnet

Rinkeby

ETH_FROM=0x3538b6eF447f244268BCb2A0E1796fEE7c45002D make deploy-rinkeby

Custom Network

ETH_RPC_URL=<your network> make deploy

Local Testnet

# on one terminal
dapp testnet
# get the printed account address from the testnet, and set it as ETH_FROM. Then:
make deploy

Verifying on Etherscan

After deploying your contract you can verify it on Etherscan using:

ETHERSCAN_API_KEY=<api-key> contract_address=<address> network_name=<mainnet|rinkeby|...> make verify

Check out the dapp documentation to see how verifying contracts work with DappTools.

Adding contracts

If you want to add your own contract to this template, you need to update the following to make it work with the deploy scripts, you'll need to:

  1. Add the new contract to the src folder.
  2. Add any constructor arguments it'll want to the helper-config.sh file.
  3. When you deploy, use make deploy-rinkeby CONTRACT=<contract-name>

Adding networks

To add new networks, simply add a new section in the Makefile like so

# kovan
deploy-kovan: export ETH_RPC_URL = $(call network,kovan)
deploy-kovan: export NETWORK=kovan
deploy-kovan: check-api-key deploy

And optionally add parameters to the helper-config.sh file.

Installing the toolkit

If you do not have DappTools already installed, you'll need to run the below commands

Install Nix

# User must be in sudoers
curl -L https://nixos.org/nix/install | sh

# Run this or login again to use Nix
. "$HOME/.nix-profile/etc/profile.d/nix.sh"

Install DappTools

curl https://dapp.tools/install | sh

DappTools Resources

dapp-templates's People

Contributors

srushtikakade28 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.