Easily interact with PoolTogether contracts using a node repl.
This project is a basic Buidler project that users Ethers.js and includes the PoolTogether contracts.
First clone the repository then run:
$ yarn
Copy over .envrc.example to .envrc
$ cp .envrc.example .envrc
Make sure to update the enviroment variables with suitable values. You'll want to administer any pools you create, so be sure to use a mnemonic that you used to create a prize pool.
Now enable the env vars using direnv
$ direnv allow
Load up the Buidler console. It will connect to Rinkeby by default:
$ buidler console
Grab the Contract loader helpers:
> const { poolAt, singleRandomWinnerAt, erc20At } = require('./loaders')
These helpers will instantiate Ethers.js Contract objects.
Now let's start talking a pool that was created using the Prize Pool Builder:
> pool = await poolAt('0xe6D68A3295Ba8ce28B5F21cBCEc562c804DF6e5F')
Let's also connect to its prize strategy:
> prizeStrategy = await singleRandomWinnerAt('0xed7E59eFffF107E0424931D76bE2De6cF42E6F73')
If you've configured the mnemonic in the envrc to be the owner of the pool and strategy, you can configure them now!
The Single Random Winner can award (almost) any tokens held by the Prize Pool to the winner. Let's award Compound Rinkeby Dai to the winner.
In the Buidler console, add Dai (Compound Rinkeby version) as an external ERC20 award to the strategy:
> await ps.addExternalErc20Award('0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa')
Now transfer 50 Dai to the prize pool:
> dai = await erc20At('0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa')
> await dai.transfer(pool.address, ethers.utils.parseEther('50'))
Next time the prize strategy awards the prize, it'll also give away 50 dai!