To deploy the contracts:
geth --testnet --fast --unlock "0" --password ~/.ethereum/testnet/password.txt
For mainnet you do NOT want to have things unlucked all the time, but for testnet this will simplify things. If you do not want to store your passphrase in a file you can unlock in the geth shell wth:
personal.unlockAccount(eth.accounts[0], 'PASSPHRASE')
You will need three addresses to use as the owner of the contracts and one contract to use as the withdrawal address. For testnet they can all be yours but for mainnet the three contracts should belong to different people and the withdrawal address should be a multisig address. You will also need enough eth in one of the addresses (we will assume account 0 below) to deploy the scripts.
cd contracts/contracts
echo "var solcOutput=`solc --optimize --combined-json abi,bin,interface Ethash.sol`" > Ethash.js
echo "var solcOutput=`solc --optimize --combined-json abi,bin,interface SmartPool.sol`" > SmartPool.js
echo "var solcOutput=`solc --optimize --combined-json abi,bin,interface SmartpoolVersion.sol`" > SmartpoolVersion.js
cd ..
cp settings.js-sample settings.js
and edit the file so it has your owner and withdrawal address in it. If you need to change the account to fund things, it should also be changed in this file. You can also change the required version of the client in this file.
geth --preload "./deploy-helpers.js" attach ~/.ethereum/testnet/geth.ipc
Then in the geth terminal:
deploy_ethash()
Once your contract is mined, put that value in the ethashAddr
variable of settings.js.
geth attach ~/.ethereum/testnet/geth.ipc --exec "eth.blockNumber/30000"
Update the epoch data. You should start with the current epoch (--from) and go at least one epoch past that (--to). You can add more epoch data later.
./epoch --keystore ~/.ethereum/testnet/keystore/ --ethash-contract $HASH --from $EPOCH --to $EPOCH+2
geth --preload "./deploy-helpers.js" attach ~/.ethereum/testnet/geth.ipc
Then in the geth terminal:
deploy_smartpool()
Once your contract is mined, put that value in the sAddr
variable of settings.js.
geth --preload "./deploy-helpers.js" attach ~/.ethereum/testnet/geth.ipc
Then in the geth terminal:
deploy_smartpoolversion()
Once your contract is mined, put that value in the gateAddr
variable of settings.js.
geth --preload "./deploy-helpers.js" attach ~/.ethereum/testnet/geth.ipc
Then in the geth terminal:
var g = load_smartpoolversion();
g.contract.updatePoolContract(sAddr, {from: funding[0]})
g.contract.updateClientVersion(version, {from: funding[0]})
Provide initial funds to the pool:
geth --preload "./deploy-helpers.js" attach ~/.ethereum/testnet/geth.ipc
Then in the geth terminal:
eth.sendTransaction({from:funding[0], to:sAddr, value: web3.toWei(20, "ether")})
A set of test code for the contracts is included. Use the following steps to run the tests against a simulated chain.
These tests requre a recent (v7 at least) version of node. v7.10.0 is known to work although more recent ones should also work.
- Install dependancies:
npm install
(sudo
might be needed on ubuntu OS) - Run:
npm test
Alternatively, you can run the commands manually:
- Run
./node_modules/.bin/testrpc -p 18545 --deterministic smartpool
- Run
./node_modules/.bin/truffle test