From 6fbd43300f5504bcf8fc560c784b837901f38a4b Mon Sep 17 00:00:00 2001 From: stubbsta Date: Wed, 20 Aug 2025 14:13:19 +0200 Subject: [PATCH] Add README to explain TST usage --- test/README.md | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 test/README.md diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..c637d36 --- /dev/null +++ b/test/README.md @@ -0,0 +1,66 @@ +# TestStableToken + +The waku-rlnv2-contract [spec](https://github.com/waku-org/specs/blob/master/standards/core/rln-contract.md) defines that DAI is to be used to pay for membership registration, with the end-goal being to deploy the contract on mainnet using an existing stable DAI token. + +Before this, we need to perform extensive testing on testnet and local environments (such as [waku-simulator](https://github.com/waku-org/waku-simulator)). During initial testing, we discovered the need to manage token minting in testnet environments to limit membership registrations and enable controlled testing of the contract. + +TestStableToken is our custom token implementation designed specifically for testing environments, providing controlled token distribution while mimicking DAI's behaviour. + +## Requirements + +- **Controlled minting**: Manage token minting through an allowlist of approved accounts, controlled by the token contract owner +- **ETH burning mechanism**: Burn ETH when minting tokens to create economic cost (WIP) +- **Proxy architecture**: Use a proxy contract to minimize updates required when the token address changes across other components (e.g., nwaku-compose repo or dogfooding instructions) + +## Usage + +### Deploy new TestStableToken with proxy contract +```bash +forge script script/DeployTokenWithProxy.s.sol:DeployTokenWithProxy --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast +``` + +### Deploy only TestStableToken contract implementation +```bash +forge script test/TestStableToken.sol:TestStableTokenFactory --tc TestStableTokenFactory --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast +``` + +### Update the proxy contract to point to the new implementation +```bash +# Upgrade the proxy to a new implementation +cast send $TOKEN_PROXY_ADDRESS "upgradeTo(address)" $NEW_IMPLEMENTATION_ADDRESS --rpc-url $RPC_URL --private-key $PRIVATE_KEY +``` + +### Add account to the allowlist to enable minting +```bash +cast send $TOKEN_PROXY_ADDRESS "addMinter(address)" $ACCOUNT_ADDRESS --rpc-url $RPC_URL --private-key $PRIVATE_KEY +``` + +### Mint tokens to the account +```bash +cast send $TOKEN_PROXY_ADDRESS "mint(address,uint256)" --rpc-url $RPC_URL --private-key $MINTER_ACCOUNT_PRIVATE_KEY +``` + +### Approve the token for the waku-rlnv2-contract to use +```bash +cast send $TOKEN_PROXY_ADDRESS "approve(address,uint256)" $TOKEN_SPENDER_ADDRESS --rpc-url $RPC_URL --private-key $PRIVATE_KEY +``` + +### Remove the account from the allowlist to prevent further minting +```bash +cast send $TOKEN_PROXY_ADDRESS "removeMinter(address)" $ACCOUNT_ADDRESS --rpc-url $RPC_URL --private-key $PRIVATE_KEY +``` + +### Query token information +```bash +# Check if an account is a minter +cast call $TOKEN_PROXY_ADDRESS "isMinter(address)" $ACCOUNT_ADDRESS --rpc-url $RPC_URL + +# Check token balance +cast call $TOKEN_PROXY_ADDRESS "balanceOf(address)" $ACCOUNT_ADDRESS --rpc-url $RPC_URL + +# Check token allowance +cast call $TOKEN_PROXY_ADDRESS "allowance(address,address)" $TOKEN_OWNER_ADDRESS $TOKEN_SPENDER_ADDRESS --rpc-url $RPC_URL +``` + + +