A great introduction to RLN was written by Rasul here, discussing the capabilities of RLN. Here's a graph to understand the dependency tree of RLN, and it's downstream users -
RLN should be used in the following scenarios -
RLN shouldn't be used in the following scenario -
By using RlnBase.sol
, as described above, you have full overriding capabilities over the registration process.
This could mean, you accept an arbitrary amount of erc20, check if the user has a soul bound token, or any other mechanism, with which you wish to verify that a given user can join your membership group.
This example will just check if the provided idCommitment starts with 0xdead
.
We will also not require a membership deposit.
Our slashing model will not use a proof, and only the owner can slash the users.
Use any of the smart contract tooling, foundry/hardhat/truffle to scaffold your project, and install rln-contract as a dependency. We will use Foundry. Installation instructions are provided here.
forge init hello_rln_app && cd hello_rln_app
rln-contract
dependency
forge install vacp2p/rln-contract
Openzeppelin-contracts
dependency
forge install Openzeppelin/openzeppelin-contracts
src/
called HelloRln.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import "rln-contract/RlnBase.sol";
import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol";
contract HelloRln is Ownable, RlnBase {
bytes2 public constant start = 0xdead;
uint256 private membershipDeposit = 0;
uint256 private depth = 20;
constructor(address _poseidonHasher) Ownable() RlnBase(membershipDeposit, depth, _poseidonHasher, address(0)) {}
function _validateRegistration(uint256 idCommitment) internal pure override {
if (bytes2(bytes32(idCommitment)) != start) revert FailedValidation();
}
function _validateSlash(uint256 idCommitment, address payable receiver, uint256[8] calldata proof)
internal
view
override
onlyOwner
{}
}
forge build
test
directory to test out this logic. A full example can be found hereOR
Most of this work would not be possible without the efforts of the PSE group and past contributors at Vac