๐ŸŠ
Token Allocator
Allocator.sol distributes tokens to addresses on a ratio defined by Governor.sol

Branch Info

Author: Austin Griffith Source code: https://github.com/scaffole-eth/scaffold-eth-examples/tree/new-allocator Intended audience: Intermediate Topics: Scaffold-eth, ERC-20 token

๐Ÿƒโ€โ™€๏ธ Quick Start

Token Allocator Example

Allocator.sol to distribute tokens/ETH at a predefined ratio to a number of addresses.
Allows the community to send funds to a neutral token distributor.

๐ŸŠ Deploying an Allocator:

1
git clone https://github.com/scaffold-eth/scaffold-eth-examples.git new-allocator
2
โ€‹
3
cd new-allocator
4
โ€‹
5
git checkout new-allocator
6
โ€‹
7
yarn install
Copied!
edit packages/hardhat/scripts/deployAllocator.js to change the Governor address
create a deployer mnemonic:
1
โ€‹
2
yarn generate
3
โ€‹
Copied!
(Fund this address by running yarn account and sending ETH to it.)
then deploy your allocator:
1
โ€‹
2
yarn deployAllocator
3
โ€‹
Copied!

๐Ÿƒโ€โ™€๏ธ Longer form ๐Ÿ— scaffold-eth instructions for working with the app/gov:

required: Node plus Yarn and Gitโ€‹
1
git clone https://github.com/austintgriffith/scaffold-eth.git new-allocator
2
โ€‹
3
cd new-allocator
4
โ€‹
5
git checkout new-allocator
Copied!
1
yarn install
Copied!
1
yarn start
Copied!
If you want to bring up a local chain and work there, edit hardhat.config.js and app.jsxhttps://github.com/austintgriffith/scaffold-eth/tree/simple-nft-example to use localhostinstead ofmainnet`.
in a second terminal window:
1
cd scaffold-eth
2
yarn chain
Copied!
in a third terminal window:
1
cd scaffold-eth
2
yarn deploy
Copied!
App:
๐Ÿ’ผ Edit your deployment script deploy.js in packages/hardhat/scripts
๐Ÿ“ฑ Open http://localhost:3000 to see the app
Contracts:
๐Ÿ” Edit the Allocator contract Allocator.sol in packages/hardhat/contracts
๐Ÿ” Edit the ExampleToken contract ExampleToken.sol in packages/hardhat/contracts
Frontend:
๐Ÿ“ Edit your frontend App.jsx in packages/react-app/src
๐Ÿ“ Edit your frontend Allocations.jsx in packages/react-app/src/views
๐Ÿ“ Edit your frontend Distributions.jsx in packages/react-app/src/views
How To:
Edit your token allocations in the deploy script deploy.js in packages/hardhat/scripts
โ€‹โ€‹
โ€‹
โ€‹
Then redeploy your contracts:
1
yarn deploy
Copied!
Your Allocations should be displayed in the frontend: โ€‹
โ€‹
โ€‹
Use the Debug tab to check the ExampleToken balance of the Allocator address: โ€‹
โ€‹
โ€‹
Use the from in the Distributions tab to distribute the token: โ€‹
โ€‹
โ€‹
Distributions can be called by anyone and they will happen at the defined ratio: โ€‹
โ€‹
โ€‹
Use address(0) to distribute ETH: โ€‹
โ€‹
โ€‹