Custodial System Bootstrap
Grassroots Economics provides a script to quickly deploy all core contracts + a sample Demurrage voucher contract that can be used for training purposes. The default values can be overridden.
Setup
Prerequistes
ge-publish
(https://github.com/grassrootseconomics/ge-publish (opens in a new tab))cast
(https://book.getfoundry.sh/getting-started/installation (opens in a new tab))- Access to an Ethereum node
- Atleast 1 ETH
ℹ️
Commmented addresses below are just placeholder addresses on Celo Alfajores testnet. You should replace them with your own addresses.
Steps
- Publish a token index:
# 0xD774bc082003eaF8DF74eEcD43AD44F03D488418
ge-publish p token-index
- Publish a user index:
# 0x5210bC940cCC4f75C387C63ECdeE1D22E9db41A1
ge-publish p user-index
- Publish a gas faucet:
# 0x8a10a01ccFac5719945eFf0a258F08eA34c1235A
ge-publish p faucet
- Publish a period backend for the gas faucet:
# 0xc90CE62237fC1AFAbD492FD517d8d71D0095E26e
ge-publish p period
- Setup the period backend:
# Set the gas faucet as the poker with setPoker(address)
cast send 0xc90CE62237fC1AFAbD492FD517d8d71D0095E26e "setPoker(address)" 0x8a10a01ccFac5719945eFf0a258F08eA34c1235A
# Set the cooldown period after which a user may request for gas again with setPeriod(uint256) [86400=24hrs]
cast send 0xc90CE62237fC1AFAbD492FD517d8d71D0095E26e "setPeriod(uint256)" 86400
# Set the balance threshold such that a user can only request for more gas if their balance is less than the threshold at that time
# 0.03 CELO ~= 5 token transfers in the worse network conditions ~= 2 KES [30000000000000000]
cast send 0xc90CE62237fC1AFAbD492FD517d8d71D0095E26e "setBalanceThreshold(uint256)" 30000000000000000
- Setup the gas faucet
# Set the top up amount: 0.03 CELO ~= 5 token transfers in the worse network conditions ~= 2 KES [30000000000000000]
cast send 0x8a10a01ccFac5719945eFf0a258F08eA34c1235A "setAmount(uint256)" 30000000000000000
# Set the period checker pointing it to the period backend
cast send 0x8a10a01ccFac5719945eFf0a258F08eA34c1235A "setPeriodChecker(address)" 0xc90CE62237fC1AFAbD492FD517d8d71D0095E26e
# Set the user index on the gas faucet (This acts as an ACL)
cast send 0x8a10a01ccFac5719945eFf0a258F08eA34c1235A "setRegistry(address)" 0x5210bC940cCC4f75C387C63ECdeE1D22E9db41A1
# Top up the faucet. This should be done regularly.
cast send --value 10ether 0x8a10a01ccFac5719945eFf0a258F08eA34c1235A
- Publish a custodial registration proxy
- Remember to reset the system account address after setting up the eth-custodial backend.
# 0x1e2FA554eF2d72F8DD6396582C2ED7a752ef8F55
ge-publish p custodial --faucet 0xc90CE62237fC1AFAbD492FD517d8d71D0095E26e --user-index 0x5210bC940cCC4f75C387C63ECdeE1D22E9db41A1 --system-account-address 0x3feCC87C2c102984865B996de340bb2C6AdCF01E
cast send 0x0f8E97ef2d6A42CF62549D4924FCBdcE83A1C6A5 "set(bytes32,address)" 0x506f6f6c496e6465780000000000000000000000000000000000000000000000 0xEDBA4dd5D72143052EDD8e799DEf52E24B4E10bd
- Setup user index
# Add the custodial registration proxy as a writer to the user index
cast send 0x5210bC940cCC4f75C387C63ECdeE1D22E9db41A1 "addWriter(address)" 0x1e2FA554eF2d72F8DD6396582C2ED7a752ef8F55
- Publish a pools index
# 0xEDBA4dd5D72143052EDD8e799DEf52E24B4E10bd
ge-publish p token-index
- Publish a contracts registry
This is the entry point to discover all other contracts.
# 0x0f8E97ef2d6A42CF62549D4924FCBdcE83A1C6A5
ge-publish p registry --identifier AccountIndex --identifier CustodialRegistrationProxy --identifier GasFaucet --identifier TokenIndex --identifier PoolIndex
- Setup the contracts registry
ℹ️
The commented string2bytes32 are fixed. You can use them as your first argumenbt to the set call.
# string to bytes32 identifiers
# cast format-bytes32-string [STRING]
# CustodialRegistrationProxy=0x437573746f6469616c526567697374726174696f6e50726f7879000000000000
# AccountIndex=0x4163636f756e74496e6465780000000000000000000000000000000000000000
# GasFaucet=0x4761734661756365740000000000000000000000000000000000000000000000
# TokenIndex=0x546f6b656e496e64657800000000000000000000000000000000000000000000
# PoolIndex=0x506f6f6c496e6465780000000000000000000000000000000000000000000000
cast send 0x0f8E97ef2d6A42CF62549D4924FCBdcE83A1C6A5 "set(bytes32,address)" 0x437573746f6469616c526567697374726174696f6e50726f7879000000000000 0x1e2FA554eF2d72F8DD6396582C2ED7a752ef8F55
cast send 0x0f8E97ef2d6A42CF62549D4924FCBdcE83A1C6A5 "set(bytes32,address)" 0x4163636f756e74496e6465780000000000000000000000000000000000000000 0x5210bC940cCC4f75C387C63ECdeE1D22E9db41A1
cast send 0x0f8E97ef2d6A42CF62549D4924FCBdcE83A1C6A5 "set(bytes32,address)" 0x546f6b656e496e64657800000000000000000000000000000000000000000000 0xD774bc082003eaF8DF74eEcD43AD44F03D488418
cast send 0x0f8E97ef2d6A42CF62549D4924FCBdcE83A1C6A5 "set(bytes32,address)" 0x506f6f6c496e6465780000000000000000000000000000000000000000000000 0xEDBA4dd5D72143052EDD8e799DEf52E24B4E10bd
cast send 0x0f8E97ef2d6A42CF62549D4924FCBdcE83A1C6A5 "set(bytes32,address)" 0x4761734661756365740000000000000000000000000000000000000000000000 0x8a10a01ccFac5719945eFf0a258F08eA34c1235A
- Add a writer to any of the published indexes
# Add a writer to the token index
cast send 0xD774bc082003eaF8DF74eEcD43AD44F03D488418 "addWriter(address)" 0x3feCC87C2c102984865B996de340bb2C6AdCF01E
- Publish some tokens and add them to the tokens index
# Publish a standard ERC20
# 0x59C463e0f3d824d34EE898EC9dFA2300e7996f5F
ge-publish p erc20--name "Kilifi" --symbol "KILIFI"
cast send 0x59C463e0f3d824d34EE898EC9dFA2300e7996f5F "mintTo(address,uint256)" 0x3feCC87C2c102984865B996de340bb2C6AdCF01E 100000000
- To deploy a pool, refer to:
https://software.grassecon.org/smart-contracts/swappool (opens in a new tab)