Git Product home page Git Product logo

solidity-contracts's Introduction

Solidity contracts

Setup

  1. Install dependencies:
npm install
  1. Create an .env file:
cp template.env .env
  1. Add wallet private key to .env file (template.env contains dummy private keys by default).

Run tests

npm test

Deployment

Deploy all contracts on networkName:

npm run deploy:{networkName}:all

Deploy a contractName on networkName:

npm run deploy:{networkName}:{contractName}

networkName is one of:

  • polygon
  • mumbai (Polygon testnet)
  • rinkeby (Ethereum testnet)

To redeploy a contract that hasn't changed, delete it's deployment file under deployments/{networkName}/ and run npm run deploy:{networkName}:{contractName} again.

To get a deployed contract's address, ABI, etc, check deployments/{networkName}/{contractName}.json.

Verification

Preparation

  1. Sign up for an account at https://etherscan.com and/or https://polygonscan.com
  2. Go to https://polygonscan.com/myapikey and/or https://polygonscan.com/myapikey to generate your API keys.
  3. Set API_KEY_ETHERSCAN and API_KEY_POLYGONSCAN in the .env file to the API keys generated in step 2.

To verify

This will verify all deployed contracts for the specified network. You can check which ones have been deployed from the .json files in the deployments/{networkName}/ folder.

npm run verify:{networkName}

networkName is one of:

  • polygon
  • mumbai (Polygon testnet)
  • rinkeby (Ethereum testnet)

Release process

  • Create a new branch
  • Make your changes in the branch (contracts + corresponding tests)
  • Open up a pull request and get confirmation that the changes are good to go
  • Deploy any contracts (see Deployment) and commit the generated artifacts. Any other services that rely on these contracts should use these artifacts.
  • Get PR approved & merged
  • Verify contracts (see Verification)

To verify legacy deployments

Setup

git clone https://github.com/poanetwork/solidity-flattener.git
cd solidity-flattener
npm install

Copy contracts to solidity-flattener directory

cp -r contracts solidity-flattener/contracts
cp node_modules/@openzeppelin solidity-flattener/contracts/@openzeppelin

Flatten solidity contract

cd solidity-flattener
npm start contract/contract.sol
  1. Open Contract on Polygonscan/rinkeby.etherscan.io , click Contract -> Verify and Publish
  2. Compiler type: Solidity (single file)
  3. Compiler version: 0.8.9
  4. License MIT
  5. Optimization -> Yes
  6. Paste flattened solidity code
  7. Get ABI encoded constructor params
    • https://abi.hashex.org/, Put contract ABI there
    • Add constructor params (for empty values add some value and remove it so its empty)
  8. Verify and publish

solidity-contracts's People

Contributors

hyperspacebunny avatar kasparpeterson avatar kristjanpeterson1 avatar patelvishal1401 avatar sergeymushta avatar snyk-bot 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.