underfitted / bnomial-web3

Smart contracts for bnomial
MIT License
0 stars 0 forks source link

bnomial-web3

Smart contracts for bnomial.

Repository Organization

The main artifacts (files and folders) in the repository are:

Setup

Local machine \ IDE agnostic

You should have npm installed, so be sure to follow the proper procedure for your OS. After that, download and install all required libraries and plugins by running:

npm install

VSCode Remote Container

You may use VSCode Remote Container if you want to avoid local installations. Just install the extension and setup your local Docker as described here.

When running the project in the development container, you may use the embedded vscode terminal to execute the deployment workflow.

:warning: The container runs all processes and update the files as the internal user node:node (1000:1000).

Develop

Smart contracts and NFTs demand an account and a blockchain network to be deployed into. Besides that, it's important to set an access provider (e.g., Alchemy or Infura) and a blockchain explorer (e.g. Polygonscan or Etherscan). Hardhat provides a built-in network to ease local development. When deploying to remote networks, you must:

Here is an example of .envfile for deploying a contract in Mumbai Net:

MUMBAI_API_URL="https://polygon-mumbai.g.alchemy.com/v2/ThIs0Is1NoT2a3VaLiD4aPi5KeY99999"
PRIVATE_KEY="1A2LoNg3BoRiNg4AnD5FAke6PriVATE7KEY8FOR9MumBAI10NETwork000999111"
POLYSCAN_KEY="0ANOTHER111FAKE22222KEY3333333HERE"

The smart contract code is in contracts/BnomialNFT.sol.

To compile it run:

npm run build

Detailed description of Bnomial project and some guidelines regarding its set up and development is available in the official documentation.

Test

The tests for the smart contract are in test/BnomialNFT.test.js.

To run the full test suite:

npm run test:full

To create the coverage report:

npm run coverage

To run the gas price estimation:

npm run gas

Test the SVG visualization

The NFT is visualized as an SVG image generated in the contract using the on-chain data. To enable easier testing, you can use the renderSVG.js script to generate the SVG images and save it as nft.svg. To run the script you can use the following command:

npm run svg

Deploy

To deploy the smart contract on the Mumbai test chain (Polygon):

npm run deploy:token:mumbai

To deploy the NFT on the Mumbai test chain (Polygon):

npm run deploy:nft:mumbai

To verify the smart contract:

npm run verify:mumbai -- <smart contract address>

Deployed contract for testing

The current NFT contract is deployed on the Mumbai testnet here: 0xefc7f192843f95acf2d851d213ee1f9f6cd8774a

The current Token contract is deployed on the Mumbai testnet here: 0xc4C99f33F686A74a2Fe95B26Ce317708f605A9eA

Setup Slither-Analyzer

Slither is a Solidity static analysis framework written in Python 3. It runs to analyze code vulnerabilities according to security aspects.

Environment

python 3.6+

Create a new virtual environment:

python -m venv .venv
source .venv/bin/activate

Install the required Python packages:

pip install -r requirements.txt

To run slither-analyzer:

npm run slither