Skip to content

Commit

Permalink
Merge pull request #13 from CommitPool/chainlink-develop
Browse files Browse the repository at this point in the history
Chainlink develop
  • Loading branch information
bitbeckers authored Dec 9, 2020
2 parents 6ffb319 + 72d63a2 commit 3be3f7e
Show file tree
Hide file tree
Showing 17 changed files with 5,376 additions and 4,111 deletions.
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
## CommitPool Single Player Smart Contract repository


[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.

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

## Features
#### Deploying to local node
Buidler

1. Use node 12 (using nvm is recommended)
2. ```npx buidler node```
3. In second terminal```npx buidler run --network localhost scripts/deploy.ts ```

Buidler & Ganache

1. Use node 12 (using nvm is recommended)
2. Start Ganache on port 8545
3. In second terminal```npx buidler run --network localhost scripts/deploy.ts ```

Truffle

1. Use node 12 (using nvm is recommended)
2. Start Ganache on port 8545
3. In terminal```truffle migrate```

#### Deploying to Matic
Deployment to the Mumbai Testnet is configured in ```./truffle-config.js```

1. ```npm install truffle -g```
2. Deploy to Mumbai testnet: ```truffle migrate --network matic```
3. Find your contract based on the address reported by Truffle in the [Matic Explorer](https://explorer-mumbai.maticvigil.com/).

Quite note on deploying to Matic:
* Test deployment using Truffle against a runnning Ganache instance: ```truffle migrate```
* Configure Matic network in [MetaMask](https://docs.matic.network/docs/develop/metamask/config-matic/)
* Request funds at [faucet](https://faucet.matic.network/)
* Use this wallet's seed phrase in the .env file to pay the deployment

Interaction with the contract on Matic via Truffle:
1. ```truffle console --network matic```
2. ```compile```
3. ```var singlePlayerCommit = await SinglePlayerCommit.at('<ADDRESS FROM DEPLOYMENT>')```
4. To test: ```await contractTest.activityKeyList(0)```

#### Interacting with the contract using Buidler
After deploying to a local node
1. ```npx buidler console --network localhost ```
2. ```const CommitPool = await ethers.getContractFactory("SinglePlayerCommit")```
3. ```const commitPool = await CommitPool.attach("<<CONTRACT ADDRESS FROM DEPLOYMENT>>")```

Example for interacting:
```await commitPool.withdraw(1000)```
## Features
[Technical documentation](https://ipfs.io/ipfs/https://ipfs.io/ipfs/QmVrBwsQ67RE9CVzyQRvDucK4LrjgB7tkAserztyBDNfJi)
#### Creation of Commitment

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.
Expand Down
5 changes: 5 additions & 0 deletions buidler.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ const config: BuidlerConfig = {
...createHDAccountConfig("kovan"),
chainId: 42,
},
localhostGanache: {
...createHDAccountConfig("ganache"),
url: "http://127.0.0.1:7545",
chainId: 5777,
},
rinkeby: {
...createHDAccountConfig("rinkeby"),
chainId: 4,
Expand Down
27 changes: 27 additions & 0 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//SPDX-License-Identifier: UNLICENSED
pragma solidity 0.6.10;

contract Migrations {
address public owner;

// A function with the signature `last_completed_migration()`, returning a uint, is required.
uint public last_completed_migration;

modifier restricted() {
if (msg.sender == owner) _;
}

constructor() public {
owner = msg.sender;
}

// A function with the signature `setCompleted(uint)` is required.
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}

function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
Loading

0 comments on commit 3be3f7e

Please sign in to comment.