Smart contracts for bnomial.
The main artifacts (files and folders) in the repository are:
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
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).
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:
.env
file and set up the required information for the network (the POLYGON_API_URL
is not needed if you are
just testing on Mumbai). The properties are: - MUMBAI_API_URL
: Alchemy HTTP URL - POLYGON_API_URL
: Alchemy HTTP URL - PRIVATE_KEY
: Deploy wallet private key - POLYSCAN_KEY
: Polygonscan API key for verificationHere is an example of .env
file 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.
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
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
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>
The current NFT contract is deployed on the Mumbai testnet here: 0xefc7f192843f95acf2d851d213ee1f9f6cd8774a
The current Token contract is deployed on the Mumbai testnet here: 0xc4C99f33F686A74a2Fe95B26Ce317708f605A9eA
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