Skip to content

Commit 3be3f7e

Browse files
authored
Merge pull request #13 from CommitPool/chainlink-develop
Chainlink develop
2 parents 6ffb319 + 72d63a2 commit 3be3f7e

17 files changed

+5376
-4111
lines changed

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
## CommitPool Single Player Smart Contract repository
22

3-
43
[CommitPool](http://commitpool.com/) helps people meet their personal goals by holding themselves accountable. CommitPool users stake money to credibly commit to meeting their goals, and lose their stake when they don’t.
54

65
Our MVP focuses on a single goal type for individuals, hence the Single Player mode.
@@ -14,8 +13,54 @@ Currently Ganache and Node 14 are not playing well together. To get started:
1413
3. ```npm run-script build```
1514
4. ```npm test``` (to verify the build)
1615

17-
## Features
16+
#### Deploying to local node
17+
Buidler
18+
19+
1. Use node 12 (using nvm is recommended)
20+
2. ```npx buidler node```
21+
3. In second terminal```npx buidler run --network localhost scripts/deploy.ts ```
22+
23+
Buidler & Ganache
1824

25+
1. Use node 12 (using nvm is recommended)
26+
2. Start Ganache on port 8545
27+
3. In second terminal```npx buidler run --network localhost scripts/deploy.ts ```
28+
29+
Truffle
30+
31+
1. Use node 12 (using nvm is recommended)
32+
2. Start Ganache on port 8545
33+
3. In terminal```truffle migrate```
34+
35+
#### Deploying to Matic
36+
Deployment to the Mumbai Testnet is configured in ```./truffle-config.js```
37+
38+
1. ```npm install truffle -g```
39+
2. Deploy to Mumbai testnet: ```truffle migrate --network matic```
40+
3. Find your contract based on the address reported by Truffle in the [Matic Explorer](https://explorer-mumbai.maticvigil.com/).
41+
42+
Quite note on deploying to Matic:
43+
* Test deployment using Truffle against a runnning Ganache instance: ```truffle migrate```
44+
* Configure Matic network in [MetaMask](https://docs.matic.network/docs/develop/metamask/config-matic/)
45+
* Request funds at [faucet](https://faucet.matic.network/)
46+
* Use this wallet's seed phrase in the .env file to pay the deployment
47+
48+
Interaction with the contract on Matic via Truffle:
49+
1. ```truffle console --network matic```
50+
2. ```compile```
51+
3. ```var singlePlayerCommit = await SinglePlayerCommit.at('<ADDRESS FROM DEPLOYMENT>')```
52+
4. To test: ```await contractTest.activityKeyList(0)```
53+
54+
#### Interacting with the contract using Buidler
55+
After deploying to a local node
56+
1. ```npx buidler console --network localhost ```
57+
2. ```const CommitPool = await ethers.getContractFactory("SinglePlayerCommit")```
58+
3. ```const commitPool = await CommitPool.attach("<<CONTRACT ADDRESS FROM DEPLOYMENT>>")```
59+
60+
Example for interacting:
61+
```await commitPool.withdraw(1000)```
62+
## Features
63+
[Technical documentation](https://ipfs.io/ipfs/https://ipfs.io/ipfs/QmVrBwsQ67RE9CVzyQRvDucK4LrjgB7tkAserztyBDNfJi)
1964
#### Creation of Commitment
2065

2166
A commitment consists of an ```activity```, a ```goalValue``` for given activity, a ```startTime```, and ```stake```. We will automagically set the ```endTime``` 7 days after the startdate.

buidler.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ const config: BuidlerConfig = {
6060
...createHDAccountConfig("kovan"),
6161
chainId: 42,
6262
},
63+
localhostGanache: {
64+
...createHDAccountConfig("ganache"),
65+
url: "http://127.0.0.1:7545",
66+
chainId: 5777,
67+
},
6368
rinkeby: {
6469
...createHDAccountConfig("rinkeby"),
6570
chainId: 4,

contracts/Migrations.sol

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//SPDX-License-Identifier: UNLICENSED
2+
pragma solidity 0.6.10;
3+
4+
contract Migrations {
5+
address public owner;
6+
7+
// A function with the signature `last_completed_migration()`, returning a uint, is required.
8+
uint public last_completed_migration;
9+
10+
modifier restricted() {
11+
if (msg.sender == owner) _;
12+
}
13+
14+
constructor() public {
15+
owner = msg.sender;
16+
}
17+
18+
// A function with the signature `setCompleted(uint)` is required.
19+
function setCompleted(uint completed) public restricted {
20+
last_completed_migration = completed;
21+
}
22+
23+
function upgrade(address new_address) public restricted {
24+
Migrations upgraded = Migrations(new_address);
25+
upgraded.setCompleted(last_completed_migration);
26+
}
27+
}

0 commit comments

Comments
 (0)