Shield: Making Tokens Private
The Shield operation is the gateway into the ZeroLayer privacy ecosystem. It's the process of converting your public, transparent ERC-20 tokens into private ZRC-20 tokens that can be used for anonymous transactions.
💰 No Protocol Fee: Shield operations are free—you only pay standard blockchain gas fees. Protocol fees only apply when unshielding (converting back to public tokens).
The Shielding Process
Shielding is conceptually similar to depositing funds into a secure vault. You lock your public tokens in the ZeroLayer smart contract and, in return, you mint an equivalent amount of private "notes" to yourself.
- Select a Token and Amount: In the ZeroLayer application, you choose which ERC-20 token you want to make private and specify the amount.
- Approve the Transfer: Your wallet will ask for your approval to allow the ZeroLayer smart contract to transfer the specified amount of your ERC-20 tokens. This is a standard and secure procedure for any DeFi application.
- Initiate the Shield: After approval, you will send the transaction to initiate the shield.
What Happens Under the Hood
When you initiate the shield, a few powerful things happen in the background:
- A New "Note" is Created: Your client creates a new cryptographic "note" (also known as a commitment). This note contains the shielded amount and is encrypted with your privacy key. Only you can see the contents of this note.
- A Zero-Knowledge Proof is Generated: Your browser generates a zk-SNARK proof. This proof mathematically demonstrates that a new note has been created for the correct amount without revealing the amount itself or who owns it.
- The Contract Verifies and Locks: The ZeroLayer smart contract receives your public ERC-20 tokens, verifies the zero-knowledge proof, and adds the commitment for your new note to its encrypted on-chain state (the Merkle tree).
Once the transaction is confirmed, your public tokens are securely held by the protocol, and you are now the sole owner of a corresponding private balance within ZeroLayer. You can now use these shielded funds to transact privately.