🐊

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:

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

🏃‍♀️ Longer form 🏗 scaffold-eth instructions for working with the app/gov:

required: Node plus Yarn and Git
git clone https://github.com/austintgriffith/scaffold-eth.git new-allocator
cd new-allocator
git checkout new-allocator
yarn install
yarn start
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:
cd scaffold-eth
yarn chain
in a third terminal window:
cd scaffold-eth
yarn deploy
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
image
Then redeploy your contracts:
yarn deploy
Your Allocations should be displayed in the frontend:
image
Use the Debug tab to check the ExampleToken balance of the Allocator address:
image
Use the from in the Distributions tab to distribute the token:
image
Distributions can be called by anyone and they will happen at the defined ratio:
image
Use address(0) to distribute ETH:
image