Code Monkey home page Code Monkey logo

gif-brownie's Introduction

GIF Brownie

This repository contains a GIF opinionated dockerized Solidity development environment based on Brownie

Prerequisites

This readme is based on the following assumption

  • You are familiar with bash shell commands
  • You are familiar with Docker
  • You are familiar with git
  • Your installation includes bash, Docker and git

PLEASE NOTE: The shell commands below are written for a bash shell. If you are working on a Windows box you may use WSL2, Git Bash on Windows or similar.

Create the Docker Image

Start with cloning the gif-brownie repository.

git clone https://github.com/etherisc/gif-brownie.git
cd gif-brownie

Build the Brownie docker image.

docker build . -t brownie

Example Usage

Create a new Project

Start a new Brownie container.

docker run -it --rm -v $PWD:/projects brownie

In the container setup a new project.

brownie init <project-name>

The name project-name is used to create a new directory and create the brownie project structure inside.

Compile and Test Smart Contracts

Start a new Brownie container.

docker run -it --rm -v $PWD:/projects brownie

In the container compile all contracts with all its dependencies.

brownie compile --all

To compile only the changed contracts/dependencies.

brownie compile

Run all test suites

brownie test

Run a specific test suite

brownie test tests/test_nft_simple.py

Run an individual test

brownie test tests/test_nft_advanced.py::test_transfer_not_owner

Use Smart Contracts Interactively

Start a new Brownie container.

docker run -it --rm -v $PWD:/projects brownie

In the container start the Brownie console

brownie console

In the Brownie console deploy and use the DummyNFT token.

>>> 
owner = accounts[0]
user1 = accounts[1]
user2 = accounts[2]

# deploy nft
nft = DummyNFT.deploy({'from':owner})

# show transaction details
history[-1].info()

# mint token for user1
tx = nft.mint(user1, {'from': owner})
tokenId = tx.return_value

# show transaction details
tx.info()

# verify user1 is owner of the new token and check her balance
nft.ownerOf(tokenId) == user1
nft.balanceOf(user1)

exit()

Start a Local Ganache Chain

As the brownie image contains an embedded Ganache chain we can also use this image to create a Ganache container as shown below.

docker run -d -p 7545:7545 --name ganache brownie ganache-cli \
    --mnemonic "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat" \
    --chainId 1234 \
    --port 7545 \
    -h "0.0.0.0"

The chosen setup deterministically creates addresses (and private keys) via a HD wallet with the mnemonic "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat". Port 7545 is chosen to avoid conflicts with any productive local ethereum client that typically run on port 8545.

To connect with Metamaks using the mnemonic as secret recovery phrase. As network parameter use http://localhost:7545 as RPC URL and 1234 as Chain ID.

Use the commands below to stop and remove the ganace container.

docker stop ganache
docker rm ganache

Use a Local Ganache Chain

TODO

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.