|
| 1 | +# Commitground Contracts |
| 2 | + |
| 3 | +This repository is used to develop & test the smart contracts for commitground using the truffle framework. |
| 4 | + |
| 5 | +# Repository Structure |
| 6 | + |
| 7 | +```.bash |
| 8 | +. |
| 9 | +├── .git |
| 10 | +├── contracts |
| 11 | +│ ├── .git |
| 12 | +│ ... |
| 13 | +│ └── Contracts.sol |
| 14 | +├── build |
| 15 | +├── migrations |
| 16 | +│ ├── 1_initial_migration.js |
| 17 | +│ └── 2_deploy_contracts.js |
| 18 | +├── package.json |
| 19 | +├── package-lock.json |
| 20 | +├── test |
| 21 | +│ ├── ... |
| 22 | +│ └── testcase.js |
| 23 | +└── truffle.js |
| 24 | +``` |
| 25 | + |
| 26 | +- `contracts`: |
| 27 | + Smart contracts written in Solidity are here. |
| 28 | + |
| 29 | +- `test`: |
| 30 | + This is a directory for test cases. Keep in mind that writing test cases is dependent on the *contract* submodule. |
| 31 | + |
| 32 | +- Etc |
| 33 | + - `build`: Build artifacts are stored in this directory. |
| 34 | + - `migtrations`: Script to test or deploy the contracts |
| 35 | + |
| 36 | +# Prerequisites |
| 37 | + |
| 38 | +1. Install truffle |
| 39 | + |
| 40 | + ```.bash |
| 41 | + npm install -g truffle |
| 42 | + ``` |
| 43 | + You can read truffle install doc [here](https://truffleframework.com/docs/getting_started/installation) |
| 44 | + |
| 45 | +1. Ganache(One click ethereum private net). |
| 46 | + |
| 47 | + Two options exist. When you run this repository on your local environment, desktop app will help you know what's happening on the blockchain. But for the CI/CD environment, 'ganache-cli' will be a better option. |
| 48 | + - [ganache-cli](https://github.com/trufflesuite/ganache-cli) |
| 49 | + - [ganache desktop app](https://truffleframework.com/ganache) |
| 50 | +
|
| 51 | +# Run test |
| 52 | +
|
| 53 | +- Running test with ganache-cli. |
| 54 | + ```.bash |
| 55 | + ./run-test.sh |
| 56 | + ``` |
| 57 | +- Running test with ganache desktop app |
| 58 | + - First, launch the ganache app |
| 59 | + - Run the following command |
| 60 | + ``` |
| 61 | + truffle test |
| 62 | + ``` |
| 63 | +
|
| 64 | +# Contributing |
| 65 | +
|
| 66 | +1. Fork this project. |
| 67 | +
|
| 68 | + - commitground-contracts: [](https://github.com/commitground/commitground-contracts/fork) |
| 69 | +
|
| 70 | +1. Clone your forked *commitground-contract* repository first. |
| 71 | +
|
| 72 | + ```.bash |
| 73 | + $ git clone https://github.com/commitground/commitground-contracts |
| 74 | + ``` |
| 75 | +
|
| 76 | +1. Make branches following the convention. Please check [this](https://github.com/commitground/guide) |
| 77 | +
|
| 78 | + ```.bash |
| 79 | + $ git checkout -b $BRANCH_NAME #e.g. feature/create-project |
| 80 | + ``` |
| 81 | +
|
| 82 | +1. Write test cases for a new contract. Read [this](https://truffleframework.com/docs/getting_started/javascript-tests) to know how to write a test case. |
| 83 | +
|
| 84 | + ```.bash |
| 85 | + $ touch test/testCreateProject.js # write test cases here |
| 86 | + ``` |
| 87 | +
|
| 88 | +1. Write a new contract & implement. |
| 89 | +
|
| 90 | + ```.bash |
| 91 | + $ touch contracts/createProject.sol # write contracts here |
| 92 | + ``` |
| 93 | +
|
| 94 | +1. Write a migration script. Read [this](https://truffleframework.com/docs/getting_started/migrations). |
| 95 | +
|
| 96 | + ```.bash |
| 97 | + $ touch migrations/n_script_title.js # write contracts here |
| 98 | + ``` |
| 99 | +
|
| 100 | +1. If it passes your test cases, push & make pull request. |
| 101 | +
|
| 102 | + ```.bash |
| 103 | + $ ./run-test.sh |
| 104 | + $ git add contracts test |
| 105 | + $ git commit -m "Add 'createProject' contract" |
| 106 | + $ git push origin $BRANCH_NAME # forked repository on your github account |
| 107 | + ``` |
0 commit comments