The example go through the following steps:
- Deploy the necessary contracts: verifier (the mock proof verifier since it's not yet generated), ERC20 token, and the RLN contract
- Create a RLN instance
rln, and demonstrate how toregister,createProof,verifyProof,withdraw, andreleaseWithdrawal. - Create a RLN instance
rlnAnotherand demonstrate how to slash a spammer.rlnAnothersimplyregisterand send more proofs than they should.rlncan detect the spam by examine the output fromsaveProof. If the status of the output is BREACH, the secret is leaked.rlncan use the recovered secret to slash the spammer by callingslash.
To install and run the example, follow the steps below.
- Install the project
$ npm install- Run a local testing RPC
Here we use a hardhat node. If the RPC is not listening
http://localhost:8545, you need to change theurlin config.ts.
In a new terminal, run:
$ npx hardhat node- Run the example
$ npm run test