We recommend using the latest versions node, npm и yarn.
To install the dependencies (after repo cloning), you must run the following command yarn install
(yarn
should be already globally istalled in your system).
By default, project is configured to use the development network:
{
host: '127.0.0.1',
port: 8545,
network_id: 5777,
gas: 3 * 10**6,
gasPrice: 20 * 10**9
}
For overriding any values of the development network, you must create a file ./config/networks/development.js which exports the overridden directives, for example:
module.exports = {
host: '172.0.0.1',
port: 8646,
gasPrice: 10 * 10**9
}
To add a new network, you must create a file named as the network, for example, ./config/networks/live.js:
module.exports = {
host: '8.8.8.8',
port: 8747,
network_id: '*',
gas: 2 * 10**6,
gasPrice: 10 * 10**9
}
By default transactions are signing by the first unlocked account of the node. For specifiyng a different account, you must add the from: <unlocked_address>
directive.
By default, it comes with deployment configuration for develop and development networks — ./config/deploy/develop.js and ./config/deploy/development.js.
Property | Required | Type | Description |
---|---|---|---|
commissionsAddress | · | String |
Address for LiquidityProvider commissions |
You may run Remix IDE by executing of yarn remix
command. It will run on http://localhost:8080. To mount local directory with contracts you should click on the chain icon in the IDE and accept prompt.
To run tests you need to execute following commands:
yarn truffle develop
# Command above will start Truffle Develop terminal
# with already running Ganache private node on 9545 port
truffle(develop)> test
Note: tests for Scrinium.sol contract may fail because of hardcoded ICO timestamps.
Before starting the deployment of smart contracts, you must have running Ethereum node (Geth, for example, or Ganache) with enabled JSON-RPC option.
The network configuration ./config/networks/<network_name>.js and deploy configuration ./config/deploy/<network_name>.js should exist.
Base account (field from
in the network configuration) should be unlocked.
# 1. Run Ganache in a separate tab
[PORT=<port>] yarn ganache # 8545 port by default
# 2. Run migrations (contracts that are already migrated will be rewritten)
[NETWORK=<network_name>] yarn migrate # development network on 8545 port by default
# 1. Unlock base account
geth attach <protocol>://<host>:<port> --exec "personal.unlockAccount(eth.accounts[0], <accountPassPhrase>)"
# 2. Run migrations (contracts that are already migrated will be rewritten)
NETWORK=<network_name> yarn migrate
# 3. Connect to the console for checking deployed contracts
geth attach <protocol>://<host>:<port> --preload ./preload-<network_name>.js
# 4. Try to run some commands such as:
> scrinium.balanceOf(eth.accounts[0]);
> balances.balanceOf(eth.accounts[0])
> platform.getTradeIds()
You may deploy contracts via Infura (to Ropsten, Rinkeby, Kovan or Mainnet networks) by running yarn migrate
with additional environment variables:
NETWORK=<network_name> \
INFURA_ACCESS_TOKEN=<infura_access_token> \
<NETWORK_NAME>_PRIVATE_KEY=<account_private_key> \
yarn migrate
-
yarn combine
— combining of smart contract sources to the ./build/combined/ directory -
yarn compile
— compilation of smart contracts from the ./contracts/ directory -
yarn ganache
— starting private blockchain (accounts are read from file ./data/ganache-cli-accounts.json)HOST=<hostname_arg>
PORT=<port_arg>
NETWORK_ID=<networkId_arg>
-
yarn lint
— linting contracts code via Solium linter -
yarn migrate
— compilation and deployment of smart contracts in the specified networkNETWORK=<network_name>
TRUFFLE_GAS=<gas_limit>
TRUFFLE_GAS_PRICE=<gas_price_in_wei>
TRUFFLE_ARTIFACTS_OUTSIDE_PATHS=<json|module|yaml>:<path_1>,...,<json|module|yaml>:<path_N>
— contracts artifacts (ABIs and addresses) will be written to all files in the paths in specified format (it will be appended to files [plain JSON, CommonJS module or YAML file])TRUFFLE_MIGRATIONS_OMIT=<migration_number_1>,...,<migration_number_N>
— specified migrations will be omittedINFURA_ACCESS_TOKEN=<infura_access_token>
<INFURA_NETWORK_NAME>_PRIVATE_KEY=<account_private_key>
-
yarn remix
— starting the Remix IDE on http://localhost:8080 with ability to mount local directory with contracts -
yarn test [-- --network <network_name> <test_file_name>]
— testing in the specified network