Skip to content

Latest commit

 

History

History
149 lines (102 loc) · 5.51 KB

deployment.md

File metadata and controls

149 lines (102 loc) · 5.51 KB

Deployment

Platform

The platform-related contracts are:

  1. allowList
  2. feeSettings
  3. TokenFactory
  4. PrivateOfferFactory
  5. CrowdinvestingFactory
  6. VestingFactory
  7. PriceLinearFactory or other dynamic pricing factories

Some of them can be deployed manually. A script is provided to automate some of the deployment steps though. It can quickly be adapted to deploy more or less of these contracts.

The script is called like this:

source .env
forge script script/DeployPlatform.s.sol:DeployPlatform --rpc-url $GOERLI_RPC_URL --broadcast --verify --private-key $PRIVATE_KEY

Note:

  • for this to work, prepare an environment file first
  • drop the --broadcast in order to simulate the transaction, but not publish it
  • edit the script (commenting out parts) to deploy less contracts
  • generally, contracts with simple constructor arguments can also be deployed without script:
    forge create --rpc-url $GOERLI_RPC_URL --private-key $PRIVATE_KEY --verify --etherscan-api-key=$ETHERSCAN_API_KEY contracts/AllowList.sol:AllowList
    forge create --rpc-url $GOERLI_RPC_URL --private-key $PRIVATE_KEY --verify --etherscan-api-key=$ETHERSCAN_API_KEY contracts/PrivateOfferFactory.sol:PrivateOfferFactory

After the contracts have been deployed like this, they are still owned by the wallet used for deployment. Don't forget to transfer ownership to a safer address, like a multisig.

Companies

The company-related contracts are:

  • Token.sol
  • Crowdinvesting.sol
  • PrivateOffer.sol

They are deployed through the web app.

For development purposes, the contracts can be deployed by adapting this script and executing it:

forge script script/DeployToken.s.sol --rpc-url $GOERLI_RPC_URL  --verify --broadcast

Forwarder

If the forwarder has not been deployed yet, e.g. when working in a testing environment, it can be deployed like this:

forge create node_modules/@opengsn/contracts/src/forwarder/Forwarder.sol:Forwarder --private-key $PRIVATE_KEY --rpc-url $GOERLI_RPC_URL --verify --etherscan-api-key $ETHERSCAN_API_KEY

Contract Verification

As the web app does not automatically verify the contracts (with etherscan or other services), this needs to be done manually. Use hardhat or foundry for this purpose. Sometimes one or the other works better.

hardhat

The Crowdinvesting contract can be verified like this:

yarn hardhat verify --network goerli 0x29b659E948616815FADCD013f6BfC767da1BDe83 0x0445d09A1917196E1DC12EdB7334C70c1FfB1623 0xA1e28D1f17b7Da62d10fbFaFCA98Fa406D759ce2 10000000000000000000 50000000000000000000 1000000 100000000000000000000 0x07865c6E87B9F70255377e024ace6630C1Eaa37F 0xc1C74cbD565D16E0cCe9C5DCf7683368DE4E35e2

Everything behind the first address is a constructor argument.

Even better is to use a file for the constructor arguments. Create a file constructorArguments.js with the following content:

module.exports = [
    "0x0445d09A1917196E1DC12EdB7334C70c1FfB1623",
    "0xA1e28D1f17b7Da62d10fbFaFCA98Fa406D759ce2",
    "10000000000000000000",
    "50000000000000000000",
    "1000000",
    "100000000000000000000",
    "0x07865c6E87B9F70255377e024ace6630C1Eaa37F",
    "0x1672E16ac9CeF8f9Fc31daFB21d637a23415DEf6"
];

And then verify like this:

npx hardhat verify --network goerli 0xC64519eC6Bd54F14323a34E122c4c798cF5AeD53 --constructor-args constructorArguments.js

Be careful to use the proper configuration in hardhat.config.js. Even if the optimizer is disabled, the number of runs configured has some influence on the resulting bytecode:

optimizer: {
        enabled: false,
        runs: 200,
      },

Verify ERC1967Proxy

npx hardhat verify --network goerli 0x676Fae4c5b791D6Cb2732C27ec794c6378ABbC04 --constructor-args script/verificationArguments/hardhat/ERC1967Proxy.js

foundry

Example for token verification:

forge verify-contract 0x458A75E83c50080279e8d8e870cF0d0F4B48C01b --constructor-args-path verificationArguments/foundry/Token --chain goerli Token

Provide the constructor arguments separated by whitespace in a file like this:

0x0445d09A1917196E1DC12EdB7334C70c1FfB1623 0x387aD1Aa745C70829b651B3F2D3E7852Df961C93 0x2Db0DD9394f851baefD1FA3334c6B188A0C0548D 0x274ca5f21Cdde06B6E4Fe063f5087EB6Cf3eAe55 0 'Max Mustermann Token' 'MAXMT'

More info can be found here.

Verify on Gnosis Chiado

Use these settings for the Chiado network:

forge [... deployment commands ...] --rpc-url $CHIADO_RPC_URL --verify --verifier blockscout --verifier-url https://gnosis-chiado.blockscout.com/api?

Verify on Gnosis Mainnet

  • blockscout

    forge script script/DeployPlatform.s.sol:DeployPlatform --private-key $PRIVATE_KEY --rpc-url $GNOSIS_RPC_URL --verify --verifier blockscout --verifier-url https://gnosis.blockscout.com/api? --resume
    

    Note that the URL provided in the output will point to gnosisscan, but that is wrong. The verification only happens on blockscout.

  • gnosisscan (requires a gnosisscan api key):

    forge script script/DeployPlatform.s.sol:DeployPlatform --private-key $PRIVATE_KEY --rpc-url $GNOSIS_RPC_URL --verify --etherscan-api-key $GNOSISSCAN_API_KEY --resume