Git Product home page Git Product logo

deploy-custom-contracts's Introduction

Overview

This project makes available contracts that can be used by any example DApp.

Building

You may build the common-contracts project as follows:

cd common-contracts
yarn && yarn build

Deploying

Usually, DApp examples that require these contracts will specify their deployment within their corresponding docker-compose.override.yml file.

Additionally, the project can be deployed manually on the local development network by running yarn deploy. Manual deployment to other supported testnets can be done by executing yarn deploy:<network>.

The Contracts

This project presents contracts that can be used by any example DApp

SimpleERC721

This is a simple contract to perform operations with NFTs.

To use it, you must first retrieve the contract address from the deployment data. For the local development network, execute the following command:

ERC_721=$(jq '.address' ./deployments/localhost/SimpleERC721.json | \
    sed "s/[\",]//g")

With that in place, you can mint a new ERC-721 token with the following command:

npx hardhat mint-token \
    --recipient 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 \
    --erc721 $ERC_721 \
    --network localhost

After the minting process finishes, a resulting token id will be printed. For example, id 1 was minted in the example below:

$ npx hardhat mint-token --recipient 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 --erc721 $ERC_721 --network localhost
Token 1 was minted for 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 at tx: 0xbb884e186fc09f65d8116e7b100c0674449b5ebf04c9a32fee9ec828007aa9b3

SimpleERC20

This is a simple contract perform operations with fungible tokens.

To use it, you must first retrieve the contract address from the deployment data. For the local development network, execute the following command:

ERC_20=$(jq '.address' ./deployments/localhost/SimpleERC20.json | \
    sed "s/[\",]//g")

With that in place, you can make transactions such as transferring tokens between accounts:

cast send $ERC_20 \
    "transfer(address,uint256)(bool)" \
    0x70997970C51812dc3A010C7d01b50e0d17dc79C8 \
    1000 \
    --mnemonic "test test test test test test test test test test test junk" \
    --mnemonic-index 0 \
    --rpc-url "http://localhost:8545"

The balance of an address can also be queried with the following command:

cast call $ERC_20 \
    "balanceOf(address)(uint32)" \
    0x70997970C51812dc3A010C7d01b50e0d17dc79C8 \
    --rpc-url "http://localhost:8545"

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.