You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains the smart contract implementation of iExec's Proof of Contribution protocol.
8
9
9
-
## Related articles
10
+
###Related articles
10
11
11
12
-[PoCo Series #1 — About Trust and Agents Incentives](https://medium.com/iex-ec/about-trust-and-agents-incentives-4651c138974c)
12
13
-[PoCo Series #2 — On the use of staking to prevent attacks](https://medium.com/iex-ec/poco-series-2-on-the-use-of-staking-to-prevent-attacks-2a5c700558bd)
@@ -19,184 +20,20 @@ This repository contains the smart contract implementation of iExec's Proof of C
All contract audit files can be found in [audits/](./audits/) folder.
45
-
46
-
# How to?
47
-
48
-
## Resources
49
-
50
-
***NPM Package**: all contract ABIs, source code, and deployment artifacts (with addresses) are bundled in the [@iexec/poco](https://www.npmjs.com/package/@iexec/poco) package.
51
-
***ABIs**: available in the `abis/` folder of this repository and in the NPM package (`/abis`).
52
-
***Deployment addresses**: published in the `deployments/` folder of this repository and in the NPM package (`/deployments/<chain>`).
53
-
***Artifacts**: ⚠️ DEPRECATED and replaced by `abis`. This will be removed in future versions.
54
-
55
-
Note: `abis/` folder contains the most up to date version of the ABIs even before deployment on live networks.
56
-
## Configure a deployment
57
-
58
-
Starting from version 5, the PoCo uses a modular design based on [ERC-2535](https://eips.ethereum.org/EIPS/eip-2535). Tests and deployment scripts will use different modules (facets) and deployment process depending on the required configuration. In particular, the configuration can use a [create2 factory](https://github.com/iExecBlockchainComputing/iexec-solidity/blob/master/contracts/Factory/GenericFactory.sol) for the deployment, and enable native token or ERC20 token based escrow depending on the targeted blockchain. This means that the codebase is the same on public blockchains (ERC20 based RLC) and dedicated sidechains (Native token based RLC).
59
-
60
-
The configuration file is located in `./config/config.json`.
61
-
62
-
It contains:
63
-
- A list of categories created during the deployment process. Additional categories can be created by the contract administrator using the `createCategory` function.
64
-
- For each chain id, a quick configuration:
65
-
- **"asset":** can be "Token" or "Native", select which escrow to use.
66
-
- **"token":** the address of the token to use. If asset is set to token, and no token address is provided, a mock will be deployed on the fly.
67
-
- **"v3":** a list of resources from a previous (v3) deployment. This allows previous resources to be automatically available. It also enables score transfer from v3 to v5. [optional]
68
-
- **"v5":** deployment parameters for the new version. If factory address is set, and no salt is provided, `bytes32(0)` will be used by default.
69
-
70
-
If you want to deploy the iExec PoCo V5 smart contracts on a new blockchain, the recommended process is to:
71
-
72
-
0. Edit the `./config/config.json` file as follows:
73
-
1. Create a new entry under "chains" with your chain id;
74
-
2. Set the asset type depending on your blockchain;
75
-
3. If you are using `"asset": "Token"`, provide the address of the token you want to use;
76
-
4. Unless you know what you are doing, leave all `"v3"` resources to `Null`;
77
-
5. Use the factory with the same salt as the other blockchains, and use the same wallet as previous deployments to have the same deployment address on this new blockchain.
Environment variable can be used to alter the configuration of a deployment:
82
-
-**SALT**: if set, the `SALT` env var will overwrite the salt parameter from the config. This can be useful to distinguish different deployments without modifying the config.
83
-
84
-
Additionally, the migration process will look for some smart contracts before deploying new instances. This is true of the application, dataset and workerpool registries. Thus, if different marketplaces are deployed to the same network, they will share these registries.
85
-
86
-
# Development
87
-
88
-
This project uses trunk-based development workflow with automatic release management. It means that:
89
-
- Only squash merge commits are accepted.
90
-
- When merging a PR, its title is used as the commit message.
91
-
- A check is added to enforce using the correct format for PR titles (feat:..., fix:..., ...).
92
-
- Release please is used to manage Github releases.
93
-
94
-
## Build
95
-
96
-
The PoCo smart contracts are in the `contracts/` folder. Json artifacts, containing the contracts bytecode and ABI can be found in the `artifacts/` folder. In case you need to regenerate them, you can use the following command:
97
-
```
98
-
npm install
99
-
npm run build
100
-
```
101
-
102
-
## Test
103
-
104
-
### Automatic testing
105
-
106
-
PoCo smart contracts come with a test suite in the `./test` folder. You can startup a sandbox blockchain and run the tests using the following command:
107
-
108
-
```
109
-
npm install
110
-
npm run test
111
-
```
112
-
113
-
Additionally, you can produce a coverage report using the following command:
114
-
```
115
-
npm run coverage
116
-
```
117
-
118
-
The automatic testing command uses the Hardhat network by default to run the tests.
119
-
120
-
### Testing on a custom blockchain
121
-
122
-
1. Start a blockchain
123
-
- You can either use the Hardhat CLI with the following command:
124
-
```
125
-
npx hardhat node [<any additional arguments>]
126
-
```
127
-
- Or run any other blockchain client.
128
-
2. **[Optional]** Update the configuration
129
-
130
-
If your blockchain listen to a port that is not 8545, or if the blockchain is on a different node, update the `hardhat.config.ts` configuration (network ports, accounts with mnemonic, ..) accordingly to the [Hardhat Configuration](https://hardhat.org/hardhat-runner/docs/config) documentation.
131
-
3. Run tests
132
-
```
133
-
npm run test -- --network <networkUrl>
134
-
```
135
-
136
-
## Deploy
137
-
138
-
The iExec PoCo contracts support automated deployment through both command-line interface and GitHub Actions workflows.
139
-
140
-
### Command Line Deployment
141
-
142
-
You can deploy the smart contracts according to the [deploy/0_deploy.ts](./deploy/0_deploy.ts) content. This will automatically save addresses of the deployed artifacts to `deployments/` folder.
143
-
144
-
To deploy using the CLI:
145
-
146
-
1. Make sure you followed the "Configure a deployment" section above
147
-
2. Enter your targeted blockchain parameters in `hardhat.config.ts`
npm run verify:all -- --network <yournetworkname> # e.g. arbitrum
167
-
```
168
-
169
-
This script automatically reads all deployed contract addresses and their constructor arguments from the deployment artifacts and verifies them on the relevant block explorer.
0 commit comments