Skip to content

Commit

Permalink
Merge pull request #335 from corpus-io/feature/deploy2gnosis
Browse files Browse the repository at this point in the history
Feature/deploy2gnosis
  • Loading branch information
malteish authored Mar 14, 2024
2 parents 6b3d4cc + b6b6210 commit 98040ee
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 69 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,22 @@ In order to improve UX, though, a frontend will be offered. In order to improve

Several of the contracts implement [EIP-2771](https://eips.ethereum.org/EIPS/eip-2771), and therefore use a trusted forwarder. The forwarder will be set in the constructor and there is no way to change it after deployment. The forwarder used will be the openGSN v2 forwarder deployed on mainnet. Some information about this contract:

- [Documentation and addresses](https://docs-v2.opengsn.org/networks/ethereum/mainnet.html)
- [Documentation and addresses](https://docs-v2.opengsn.org/)
- [Code](https://github.com/opengsn/gsn/blob/v2.2.5/packages/contracts/src/forwarder/Forwarder.sol)
- [Audit reports](https://docs-v2.opengsn.org/audits.html)
- Deployment: **0xAa3E82b4c4093b4bA13Cb5714382C99ADBf750cA**
- Deployment on Ethereum Mainnet: **0xAa3E82b4c4093b4bA13Cb5714382C99ADBf750cA**

- deployed 2022-04-21
- [official resources](https://docs-v2.opengsn.org/networks/xdai/xdai.html)
- Visit on [etherscan](https://etherscan.io/address/0xaa3e82b4c4093b4ba13cb5714382c99adbf750ca) ([see transactions here](https://etherscan.io/txsInternal?a=0xAa3E82b4c4093b4bA13Cb5714382C99ADBf750cA&&m=advanced&p=1))
- This [dashboard](https://dune.com/oren/meta-transactions-on-ethereum-over-time) lists the forwarder as second most active forwarder contract with over 2000 transactions executed
- used in our [tests](./test/CrowdinvestingERC2771.t.sol).

- Deployment on Gnosis Chain: **0x7eEae829DF28F9Ce522274D5771A6Be91d00E5ED**
- deployed 2021-04-29
- [official resources](https://docs-v2.opengsn.org/networks/xdai/xdai.html)
- visit on [blockscout](https://gnosis.blockscout.com/address/0x7eEae829DF28F9Ce522274D5771A6Be91d00E5ED)

The platform will maintain a hot wallet (EOA) in order to send transactions to the forwarder contract. This results in the following flow:

- contract A supports EIP-2771 and uses `forwarder` as its (one and only, immutable) trusted forwarder
Expand Down
29 changes: 28 additions & 1 deletion docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ forge script script/DeployToken.s.sol --rpc-url $GOERLI_RPC_URL --verify --broa
## 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`

```
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

Expand Down Expand Up @@ -120,3 +123,27 @@ Provide the constructor arguments separated by whitespace in a file like this:
```

More info can be found [here](https://book.getfoundry.sh/reference/forge/forge-verify-contract).

#### 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
```
47 changes: 47 additions & 0 deletions docs/deployments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Deployments

## Production

The contracts are deployed to these production networks:

- Ethereum Mainnet
- [Gnosis Chain](https://www.gnosis.io/)

These are the most relevant contracts. Those that we deployed were verified on blockscout and gnosisscan, as both explorers seem to be used by the community.

| Contract | Ethereum Mainnet | Gnosis Chain (fomerly xDai chain) | | Comment |
| -------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------- | ------- |
| Forwarder | | [0x7eEae829DF28F9Ce522274D5771A6Be91d00E5ED](https://gnosis.blockscout.com/address/0x7eEae829DF28F9Ce522274D5771A6Be91d00E5ED) | These were deployed by the GSN team |
| FeeSettingsCloneFactory | | [0x2659B6c5121049626363dBc1d22f267e79a0BFDE](https://gnosisscan.io/address/0x2659b6c5121049626363dbc1d22f267e79a0bfde) | |
| AllowListCloneFactory | | [0x2b27853251fcEc49617f7a3E2C9809108CCC36d6](https://gnosisscan.io/address/0x2b27853251fcec49617f7a3e2c9809108ccc36d6) | |
| TokenProxyFactory | | [0x994257AcCF99E5995F011AB2A3025063e5367629](https://gnosisscan.io/address/0x994257accf99e5995f011ab2a3025063e5367629) | |
| VestingCloneFactory | | [0xCCC45E788bcf916b3b7cA79c2e1A1fC694aD03F7](https://gnosisscan.io/address/0xccc45e788bcf916b3b7ca79c2e1a1fc694ad03f7) | |
| PrivateOfferFactory | | [0x66330A3718F68c293046d39498EDC6a043CF7190](https://gnosisscan.io/address/0x66330a3718f68c293046d39498edc6a043cf7190) | |
| FeeSettings | | [0xFce9A1e8C063162f4F54f84ab8B2744D3Efc15A2](https://gnosisscan.io/address/0xFce9A1e8C063162f4F54f84ab8B2744D3Efc15A2) | |
| AllowList | | [0xf2c479836b1f23eBE127CFB3B6dabf535d60B6DD](https://gnosisscan.io/address/0xf2c479836b1f23ebe127cfb3b6dabf535d60b6dd) |
| CrowdinvestingCloneFactory | | [0x470586e0a7c2E641c39930B96E58E4300Be32cF3](https://gnosisscan.io/address/0x470586e0a7c2e641c39930b96e58e4300be32cf3) | | |
| monerium | | [0xcB444e90D8198415266c6a2724b7900fb12FC56E](https://gnosis.blockscout.com/token/0xcB444e90D8198415266c6a2724b7900fb12FC56E) | these were deployed by the monerium team |

## Testing

The contracts are deployed to these testing networks:

- Sepolia
- [Chiado](https://docs.gnosischain.com/concepts/networks/chiado)

| Contract | Sepolia | Chiado | | Comment |
| -------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | ------- |
| Forwarder | | [0x2659B6c5121049626363dBc1d22f267e79a0BFDE](https://gnosis-chiado.blockscout.com/address/0x2659B6c5121049626363dBc1d22f267e79a0BFDE) | |
| FeeSettingsCloneFactory | | [0xf2c479836b1f23eBE127CFB3B6dabf535d60B6DD](https://blockscout.chiadochain.net/address/0xf2c479836b1f23ebe127cfb3b6dabf535d60b6dd) | |
| AllowListCloneFactory | | [0xCCC45E788bcf916b3b7cA79c2e1A1fC694aD03F7](https://blockscout.chiadochain.net/address/0xccc45e788bcf916b3b7ca79c2e1a1fc694ad03f7) | |
| TokenProxyFactory | | [0x470586e0a7c2E641c39930B96E58E4300Be32cF3](https://blockscout.chiadochain.net/address/0x470586e0a7c2e641c39930b96e58e4300be32cf3) | |
| VestingCloneFactory | | [0x2CC672eac7326DC0c3E19d1B313548346Eb10FD8](https://blockscout.chiadochain.net/address/0x2cc672eac7326dc0c3e19d1b313548346eb10fd8) | |
| PrivateOfferFactory | | [0x994257AcCF99E5995F011AB2A3025063e5367629](https://blockscout.chiadochain.net/address/0x994257accf99e5995f011ab2a3025063e5367629) | |
| FeeSettings | | [0xab32D71F81CB897C17C9474059466bF7e117384c](https://blockscout.chiadochain.net/address/0xab32D71F81CB897C17C9474059466bF7e117384c) | |
| AllowList | | [0x774AE1a25964A0DbA498Ff7b7B59B2877B0F5be6](https://blockscout.chiadochain.net/address/0x774ae1a25964a0dba498ff7b7b59b2877b0f5be6) |
| CrowdinvestingCloneFactory | | [0x53B5E6Acd59021E61495AbD30796b09A25c880eD](https://blockscout.chiadochain.net/address/0x53b5e6acd59021e61495abd30796b09a25c880ed) | |
| tokenize.it_USDC | | [0xC3Ea9c8BF307c7022670C88dF0357E28DA975267](https://blockscout.chiadochain.net/address/0xc3ea9c8bf307c7022670c88df0357e28da975267) | |
| tokenize.it_EUROC | | [0x730653cEB98334937431e27be111369a90B9aCc7](https://blockscout.chiadochain.net/address/0x730653ceb98334937431e27be111369a90b9acc7) | |
| monerium | | [0xb106ed7587365a16b6691a3D4B2A734f4E8268a2](https://gnosis-chiado.blockscout.com/address/0xb106ed7587365a16b6691a3D4B2A734f4E8268a2) | these were deployed by the monerium team |

On chiado, the platform cold wallet is a simple EOA with this address: 0x99b686F27413fd41F338aDD3Bce2eb60bBa7885E.
4 changes: 3 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ optimizer_runs = 10_000
gas_reports = ["AllowList", "Crowdinvesting", "FeeSettings", "PrivateOffer", "PrivateOfferFactory", "Token"]

[rpc_endpoints]
goerli = "${GOERLI_RPC_URL}"
goerli = "${GOERLI_RPC_URL}"
chiado = "${CHIADO_RPC_URL}"
gnosis = "${GNOSIS_RPC_URL}"
9 changes: 7 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ const config: HardhatUserConfig = {
localhost: {
url: 'http://localhost:8545',
},
ropsten: {
url: process.env.ROPSTEN_URL || '',
chiado: {
url: process.env.CHIADO_RPC_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
gnosis: {
url: process.env.GNOSIS_RPC_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
Expand Down
139 changes: 76 additions & 63 deletions script/DeployPlatform.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ contract DeployPlatform is Script {
function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployerAddress = vm.addr(deployerPrivateKey);
address platformColdWallet = 0x9E23f8AA17B2721cf69D157b8a15bd7b64ac881C; // Sepolia and Mainnet

/*
* config
Expand All @@ -36,84 +35,98 @@ contract DeployPlatform is Script {
// trustedCurrencies[5] = address(0xcB444e90D8198415266c6a2724b7900fb12FC56E); // EURe

// Mainnet
address trustedForwarder = 0xAa3E82b4c4093b4bA13Cb5714382C99ADBf750cA;
address[] memory trustedCurrencies = new address[](6);
trustedCurrencies[0] = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // WEth
trustedCurrencies[1] = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); // WBTC
trustedCurrencies[2] = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); // USDC
trustedCurrencies[3] = address(0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c); // EUROC
trustedCurrencies[4] = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); // DAI
trustedCurrencies[5] = address(0x3231Cb76718CDeF2155FC47b5286d82e6eDA273f); // EURe
// address platformColdWallet = 0x9E23f8AA17B2721cf69D157b8a15bd7b64ac881C;
// address trustedForwarder = 0xAa3E82b4c4093b4bA13Cb5714382C99ADBf750cA;
// address[] memory trustedCurrencies = new address[](6);
// trustedCurrencies[0] = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // WEth
// trustedCurrencies[1] = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); // WBTC
// trustedCurrencies[2] = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); // USDC
// trustedCurrencies[3] = address(0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c); // EUROC
// trustedCurrencies[4] = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); // DAI
// trustedCurrencies[5] = address(0x3231Cb76718CDeF2155FC47b5286d82e6eDA273f); // EURe

// Sepolia
// address platformColdWallet = 0x9E23f8AA17B2721cf69D157b8a15bd7b64ac881C;
// address trustedForwarder = 0x274ca5f21Cdde06B6E4Fe063f5087EB6Cf3eAe55;
// address[] memory trustedCurrencies = new address[](2);
// trustedCurrencies[0] = address(0x30627856Ef668F0A6a1ca9145C9538f7d5b42BDE); // tEUROC
// trustedCurrencies[1] = address(0x86f488C7CC923d987b246994a0E5e20B3364fd92); // tUSDC

// Gnosis Chiado
// address platformColdWallet = 0x99b686F27413fd41F338aDD3Bce2eb60bBa7885E;
// address trustedForwarder = 0x2659B6c5121049626363dBc1d22f267e79a0BFDE;
// address[] memory trustedCurrencies = new address[](6);
// trustedCurrencies[0] = address(0xb106ed7587365a16b6691a3D4B2A734f4E8268a2); // Monerium

// Gnosis Mainnet
address platformColdWallet = 0x9E23f8AA17B2721cf69D157b8a15bd7b64ac881C;
address trustedForwarder = 0x7eEae829DF28F9Ce522274D5771A6Be91d00E5ED;
address[] memory trustedCurrencies = new address[](6);
trustedCurrencies[0] = address(0xcB444e90D8198415266c6a2724b7900fb12FC56E); // Monerium

/*
* execution
*/
console.log("Deployer address: ", deployerAddress);
vm.startBroadcast(deployerPrivateKey);

// console.log("Deploying FeeSettingsCloneFactory contract...");
// FeeSettings feeSettingsLogicContract = new FeeSettings(trustedForwarder);
// FeeSettingsCloneFactory feeSettingsCloneFactory = new FeeSettingsCloneFactory(
// address(feeSettingsLogicContract)
// );
// console.log("FeeSettingsCloneFactory deployed at: ", address(feeSettingsCloneFactory));

// console.log("Deploying FeeSettings contract...");
// Fees memory fees = Fees(200, 600, 200, 0);
// FeeSettings feeSettings = FeeSettings(
// feeSettingsCloneFactory.createFeeSettingsClone(
// bytes32(0),
// trustedForwarder,
// platformColdWallet,
// fees,
// platformColdWallet,
// platformColdWallet,
// platformColdWallet
// )
// );
// console.log("FeeSettings deployed at: ", address(feeSettings));

// console.log("Deploying AllowListCloneFactory contract...");
// AllowList allowListLogicContract = new AllowList(trustedForwarder);
// AllowListCloneFactory allowListCloneFactory = new AllowListCloneFactory(address(allowListLogicContract));
// console.log("AllowListCloneFactory deployed at: ", address(allowListCloneFactory));

// console.log("Deploying AllowList contract...");

// uint256[] memory attributes = new uint256[](trustedCurrencies.length);
// for (uint256 i = 0; i < trustedCurrencies.length; i++) {
// attributes[i] = TRUSTED_CURRENCY;
// }
// AllowList allowList = AllowList(
// allowListCloneFactory.createAllowListClone(
// bytes32(0),
// trustedForwarder,
// platformColdWallet,
// trustedCurrencies,
// attributes
// )
// );
// console.log("Allowlist deployed at: ", address(allowList));
console.log("Deploying FeeSettingsCloneFactory contract...");
FeeSettings feeSettingsLogicContract = new FeeSettings(trustedForwarder);
FeeSettingsCloneFactory feeSettingsCloneFactory = new FeeSettingsCloneFactory(
address(feeSettingsLogicContract)
);
console.log("FeeSettingsCloneFactory deployed at: ", address(feeSettingsCloneFactory));

console.log("Deploying FeeSettings contract...");
Fees memory fees = Fees(200, 600, 200, 0);
FeeSettings feeSettings = FeeSettings(
feeSettingsCloneFactory.createFeeSettingsClone(
bytes32(0),
trustedForwarder,
platformColdWallet,
fees,
platformColdWallet,
platformColdWallet,
platformColdWallet
)
);
console.log("FeeSettings deployed at: ", address(feeSettings));

console.log("Deploying AllowListCloneFactory contract...");
AllowList allowListLogicContract = new AllowList(trustedForwarder);
AllowListCloneFactory allowListCloneFactory = new AllowListCloneFactory(address(allowListLogicContract));
console.log("AllowListCloneFactory deployed at: ", address(allowListCloneFactory));

console.log("Deploying AllowList contract...");

uint256[] memory attributes = new uint256[](trustedCurrencies.length);
for (uint256 i = 0; i < trustedCurrencies.length; i++) {
attributes[i] = TRUSTED_CURRENCY;
}
AllowList allowList = AllowList(
allowListCloneFactory.createAllowListClone(
bytes32(0),
trustedForwarder,
platformColdWallet,
trustedCurrencies,
attributes
)
);
console.log("Allowlist deployed at: ", address(allowList));

// console.log("Deploying VestingCloneFactory contract...");
// Vesting vestingImplementation = Vesting(0xa740Dd991655b2887321C71D8Ac0c171a0C9E969);
// VestingCloneFactory vestingCloneFactory = new VestingCloneFactory(address(vestingImplementation));
// console.log("VestingCloneFactory deployed at: ", address(vestingCloneFactory));
console.log("Deploying VestingCloneFactory contract...");
Vesting vestingImplementation = Vesting(0xa740Dd991655b2887321C71D8Ac0c171a0C9E969);
VestingCloneFactory vestingCloneFactory = new VestingCloneFactory(address(vestingImplementation));
console.log("VestingCloneFactory deployed at: ", address(vestingCloneFactory));

// console.log("Deploying PrivateOfferFactory contract...");
// PrivateOfferFactory privateOfferFactory = new PrivateOfferFactory(vestingCloneFactory);
// console.log("PrivateOfferFactory deployed at: ", address(privateOfferFactory));
console.log("Deploying PrivateOfferFactory contract...");
PrivateOfferFactory privateOfferFactory = new PrivateOfferFactory(vestingCloneFactory);
console.log("PrivateOfferFactory deployed at: ", address(privateOfferFactory));

// console.log("Deploying TokenProxyFactory contract...");
// Token tokenImplementation = new Token(trustedForwarder);
// TokenProxyFactory tokenProxyFactory = new TokenProxyFactory(address(tokenImplementation));
// console.log("TokenProxyFactory deployed at: ", address(tokenProxyFactory));
console.log("Deploying TokenProxyFactory contract...");
Token tokenImplementation = new Token(trustedForwarder);
TokenProxyFactory tokenProxyFactory = new TokenProxyFactory(address(tokenImplementation));
console.log("TokenProxyFactory deployed at: ", address(tokenProxyFactory));

// console.log("Deploying Tokens to use as currrency on testnet...");
// Token tUSDC = Token(
Expand Down

0 comments on commit 98040ee

Please sign in to comment.