Transaction Filterer
Prividium transaction filterer is an optional contract that allows to control what kind of L1->L2 transactions are added to the queue to be executed.
In particular, it can be used to only allow ETH and ERC20 token deposits to the chain, unless the address is whitelisted on the transaction filterer contract.
The filterer is one part of enabling deposits. For the full setup — L2 permissions, this filterer, and frontend settings — see Enabling Bridging.
Deployment and configuration
These are the steps to deploy and configure the transaction filterer on an otherwise deployed chain:
- Clone the contracts repo and install dependencies:
git clone -b zksync-os-stable https://github.com/matter-labs/era-contracts --recursive
cd era-contracts/l1-contracts
yarn install- Simulate deployment and configuration of the PrividiumTransactionFilterer.sol.
BRIDGEHUB_ADDRESS=... # Address of the L1 Bridgehub
CHAIN_ADMIN_PK=... # Private key of the Prividium chain admin, can be used to upgrade the filterer contract
FILTERER_OWNER_PK=... # Private key of the filterer contract owner, cannot be the same as chain admin
CHAIN_ID=... # Chain ID of the Prividium chain
DEPOSITS_ALLOWED=... # `true` or `false` - whether or not to allow depositing for non-whitelisted addresses
L1_RPC_URL=...
forge script deploy-scripts/DeployPrividiumTransactionFilterer.s.sol \
--sig 'run(address,uint256,bool)' $BRIDGEHUB_ADDRESS $CHAIN_ID $DEPOSITS_ALLOWED \
--private-keys $CHAIN_ADMIN_PK \
--private-keys $FILTERER_OWNER_PK \
--sender $(cast wallet address $FILTERER_OWNER_PK) \
--rpc-url $L1_RPC_URL- Run the same command, with
--broadcastappended at the end to send the transactions on chain. After this command succeeds, the transaction filterer is deployed and configured.
Whitelisting addresses
Only addresses whitelisted on the transaction filterer contract are able to perform arbitrary L1->L2 transactions. All
other EOA addresses are only able to perform deposits to their own address, if depositsAllowed is set to true.
Note, that contracts' addresses are aliased during depositing, which means that L1 contracts will not be able to perform
deposits unless whitelisted.
- To add an address to the whitelist, call
grantWhitelist(address sender)method - To remove an address from the whitelist, call
revokeWhitelist(address sender)method - To toggle deposits permission (i.e. to allow/disallow depositing for non-whitelisted addresses), call
setDepositsAllowed(bool allowed)method
All 3 of these methods can only be called by the owner of the transaction filterer contract.
Example:
cast send $FILTERER_ADDRESS 'grantWhitelist(address)' $ADDRESS_TO_WHITELIST --private-key $FILTERER_OWNER_PK --rpc-url $L1_RPC_URL --broadcast