Solidity based smart contracts that power the PlayVig x DBET contracts. Details about the contract architecture and functionality can be found in the Architecture Wiki
The contracts are split into the following types:
-
Install Vechain Thor
-
Install Ganache-cli (to run tests)
-
Clone this repository
-
Install the repository packages
npm install
-
Run Vechain Thor using the following command to run testnet
bin/thor --network test
Or run using the following command to run Thor in solo mode (equivalent of ganache-cli for Thor)
bin/thor solo --on-demand
-
Configure your deployments according to the Configuration section
-
To compile a fresh set of contracts, run
npm run compile
This will not run if contracts have already been compiled. Delete ./build/contracts if you'd like to re-run this command.
-
To migrate/deploy contracts, run
npm run migrate
You can also specify chains by adding it as an arg,
npm run migrate --chain solo
Note that this will auto-compile contracts if ./build/contracts is empty
-
To run tests, run Ganache-cli with the following configuration
For development (Use a network ID of 10)
ganache-cli --mnemonic "mimic soda meat inmate cup someone labor odor invest scout fat ketchup" -i 10
-
Add an .env file to the current directory with the following variables
MNEMONIC='<MNEMONIC TO DEPLOY CONTRACTS AND CONTR˚OL THE PLATFORM>' INFURA_KEY='<REGISTERED INFURA KEY>' DEFAULT_ACCOUNT='<DEFAULT ACCOUNT LINKED TO YOUR MNEMONIC>' ADMIN_ADDRESS='<ADDRESS OF ADMIN FOR PLATFORM CONTRACTS>'
While running the migration script - the configuration is retrieved from vet-config.js. Each chain can be assigned a different set of configuration parameters. The parameters that can be changed are:
- host - The IP of the Thor node URL. Default: 'localhost'
- port - Port of the Thor node URL. Default: 8669
- chain_tag - Chain tag of the network. Default: '0xcf'
- gasPrice - Gas price while deploying contracts. Default: '100000000000'
- privateKey - Private key for address deploying contracts.
Tests would have to be run using ganache-cli as a simulation chain, this is because Thor does not support RPC calls such as evm_snapshot which are exclusive to ganache-cli.
The test configuration can be changed in truffle-config.js. Whereas migration scripts can be found in ./migrations/test.
Note that Vechain specific functionality such as MPP will NOT work with tests and is intended to test solely solidity contract code.
To run tests, run the following commands
-
All tests
npm run test
-
Admin
npm run test-admin
-
Quest
npm run test-quest
-
Tournament
npm run test-tournament