Shield Contract
The Shield contract manages access policies on the Base blockchain.Contract Address
Overview
The Shield contract stores access policies that define:- Who can access content (recipient)
- When access expires (timestamp)
- How many attempts are allowed (maxAttempts)
- How many attempts have been made (attempts)
Data Structures
AccessPolicy
Storage
policyId (keccak256 hash).
Functions
createPolicy
Create a new access policy.
Requirements:
- Policy doesn’t already exist
- Recipient is not zero address
- Expiry is in the future
- maxAttempts > 0
PolicyCreated
Example:
logAttempt
Log an access attempt. Must be called by recipient.
Requirements:
- Policy exists
- Policy is valid
- Caller is the recipient
- Not expired
- Attempts remaining
VerificationAttempt
Example:
isPolicyValid
Check if a policy is currently valid.true if:
- Policy exists
validflag is true- Not expired
- Attempts remaining
Events
PolicyCreated
VerificationAttempt
Access Control
Error Messages
Flow Example
Creating a Link
Accessing Content
Security Considerations
- Immutable policies: Once created, cannot be modified
- Self-enforcing: Rules are enforced by contract, not trust
- Transparent: All policies and attempts are public
- Auditable: Complete history on-chain

