This repository is used to develop & test the smart contracts for commitground using the truffle framework.
.
├── .git
├── contracts
│ ├── .git
│ ...
│ └── Contracts.sol
├── build
├── migrations
│ ├── 1_initial_migration.js
│ └── 2_deploy_contracts.js
├── package.json
├── package-lock.json
├── test
│ ├── ...
│ └── testcase.js
└── truffle.js
-
contracts
: Smart contracts written in Solidity are here. -
test
: This is a directory for test cases. Keep in mind that writing test cases is dependent on the contract submodule. -
Etc
build
: Build artifacts are stored in this directory.migtrations
: Script to test or deploy the contracts
-
Install truffle
npm install -g truffle
You can read truffle install doc here
-
Ganache(One click ethereum private net).
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.
- Running test with ganache-cli.
./run-test.sh
- Running test with ganache desktop app
- First, launch the ganache app
- Run the following command
truffle test
-
Fork this project.
-
Clone your forked commitground-contract repository first.
$ git clone https://github.com/commitground/commitground-contracts
-
Make branches following the convention. Please check this
$ git checkout -b $BRANCH_NAME #e.g. feature/create-project
-
Write test cases for a new contract. Read this to know how to write a test case.
$ touch test/testCreateProject.js # write test cases here
-
Write a new contract & implement.
$ touch contracts/createProject.sol # write contracts here
-
Write a migration script. Read this.
$ touch migrations/n_script_title.js # write contracts here
-
If it passes your test cases, push & make pull request.
$ ./run-test.sh $ git add contracts test $ git commit -m "Add 'createProject' contract" $ git push origin $BRANCH_NAME # forked repository on your github account