Automated DataCap allocation for Filecoin Storage Providers based on Burn-to-Earn mechanism.
AutoCap is a Filecoin FVM smart contract that automates the allocation of DataCap to Storage Providers (SPs) based on how much FIL they have burned through the Filecoin Pay rail.
The contract operates on a per-round basis:
- Registration Phase: SPs register by paying a fee and providing their Actor ID
- Calculation Phase: Owner inputs off-chain burn verification data
- Distribution Phase: DataCap is distributed proportionally to each SP's FIL burn
Allocation = (ParticipantBurnt × DistributableDataCap) / TotalGlobalBurnt
┌─────────────────────────────────────────────────────────────┐
│ AutoCap │
├─────────────────────────────────────────────────────────────┤
│ State: RegistrationOpen → Calculation → Distributing │
├─────────────────────────────────────────────────────────────┤
│ Participants │
│ ├── isRegistered │
│ ├── datacapActorId (destination for DataCap) │
│ ├── filBurnt (set by oracle) │
│ └── hasClaimed │
├─────────────────────────────────────────────────────────────┤
│ DataCap Actor (f07) ←──── FRC42 ────→ AutoCap │
└─────────────────────────────────────────────────────────────┘
- Foundry
- Git
# Clone the repository
git clone https://github.com/your-org/autocap-v0.git
cd autocap-v0
# Install dependencies
forge install OpenZeppelin/openzeppelin-contracts
forge install Zondax/filecoin-solidity
# Build
forge buildforge buildforge testforge test -vvvvforge fmtforge snapshotCreate a .env file:
PRIVATE_KEY=your_private_key
PAYMENT_CONTRACT=0x... # Filecoin Pay contract address
REGISTRATION_FEE=100000000000000000 # 0.1 FIL in AttoFILsource .env
forge script script/Deploy.s.sol:DeployAutoCap \
--rpc-url https://api.calibration.node.glif.io/rpc/v1 \
--broadcast# Start local node
anvil
# Deploy
forge script script/Deploy.s.sol:DeployAutoCapLocal \
--rpc-url http://localhost:8545 \
--broadcast// Register for the round
function register(uint64 _datacapActorId) external payable;// Close registration phase
function closeRegistration() external;
// Set burn statistics (batched)
function setParticipantBurnStats(address[] calldata _sps, uint256[] calldata _amounts) external;
// Finalize round and enable distribution
function finalizeRound(uint256 _totalFilBurntInRound) external;
// Withdraw collected registration fees
function withdrawFees() external;// Claim DataCap for beneficiaries (batched)
function claimDataCap(address[] calldata _beneficiaries) external;event Registered(address indexed sp, uint64 datacapActorId);
event BurnStatsUpdated(address indexed sp, uint256 amount);
event RoundFinalized(uint256 totalFilBurnt, uint256 distributableDataCap);
event DataCapClaimed(address indexed sp, uint256 amount);
event DataCapReceived(uint256 amount, bytes operatorData);
event RegistrationClosed();
event FeesWithdrawn(address indexed owner, uint256 amount);- Owner Trust: The contract relies on the owner as an oracle for burn verification
- Actor ID Validation: Users must provide correct Actor IDs; invalid IDs result in lost DataCap
- Gas Limits: Batch operations (setParticipantBurnStats, claimDataCap) should be split if too many participants
- OpenZeppelin Contracts - Access control
- Filecoin Solidity - DataCap Actor interaction
MIT