To play with geth
, we provide a js library to simplify the contracts calls.
You can download ETH_geth.js
is a wrapper for web3 calls, used by PoolManager.js
provides methods to access the contract directly in an easy way.
USING POOLMANAGER IN GETH:
1 - open your geth
console as usual.
2 - load the scripts :
on Linux :
on Windows: (note the double '\')
3 - load the pools :
Then you can call in your console
You'll see the active and ended pools
4 - buy tickets for a pool (replace poolIndex and ticketCount):
This will send the transaction to the contract with the correct amount (ticketCount * ticketPrice)
NB : your account need to be unlocked (personal.unlockAccount(), more info here
Wait a bit (maximum 30 secs) for the transaction to be mined before refreshing the pools (see other commands below)
- refresh the pools
This will refresh all the pools info (active and ended)
or you can refresh only one pool with its index:
var pool = PoolManager.getPool(index); // for an active pool
var poolDone = PoolManager.getPoolDone(index); // for an ended pool
each call to the load method will refresh the info
- check for a win
When a pool is ended, it goes into the pool done array, and the winner is picked 1 hour later
, you can do :
(replace index by the pool you want to check)
var poolDone = PoolManager.getPoolDone(index);
if it's 0x0000000000..., the winner is not picked yet
or just :
poolDone; //to see all its info
- send its price to winner
This sends the pool money to the winner. This is done automatically by our console, but anyone can call it too (this costs gas)
- changing account
You can change the account sending the transactions (like buy tickets)
ETH.account = 'your_eth_addr'
(replace your_eth_addr by 0x..... inside the quotes)
ETH.account = eth.accounts
(if you have multiple accounts set)
By default, the account is eth.coinbase
The following commands are used to update the states of the pools.
They are called automatically by our console, since they cost some gas... But you are free to call them too :-)
This check if an active pool is ended, and restart one if it is (this costs a lot of gas)
If the pool was ended, it goes into the poolDone array
You can use PoolManager.loadPools() to refresh the pools at any time to see active and ended pools
This check if a ended pool can be terminated (if one hour has passed since the ended state), and pick a winner if it can.
This clear the poolDone array, when all the money have been sent
Our console send the money to the winner automatically