Storage contracts are smart contracts that govern the relationship between users (renters) and storage providers (nodes) on the DÆTA network.
stateDiagram-v2
[*] --> Negotiation
Negotiation --> Active: Terms Agreed
Active --> Renewal: Contract Expiring
Active --> Terminated: Terms Violated
Active --> Completed: Contract Fulfilled
Renewal --> Active: New Terms Agreed
Renewal --> Terminated: No Agreement
Completed --> [*]
Terminated --> [*]
Length of the storage agreement.
90 days.
Amount of data to be stored.
100GB.
Number of copies to maintain.
3x.
Minimum node availability.
99.9%.
Frequency of payments to nodes.
Weekly.
Consequences for contract violations.
10% stake slash.
pragma solidity ^0.8.0;
contract DAETAStorageContract {
address public renter;
address public provider;
uint256 public dataSize;
uint256 public duration;
uint256 public price;
uint256 public startTime;
bool public active;
event ContractCreated(address renter, address provider, uint256 dataSize);
event ContractFulfilled(address renter, address provider);
constructor(address _provider, uint256 _dataSize, uint256 _duration) payable {
renter = msg.sender;
provider = _provider;
dataSize = _dataSize;
duration = _duration;
price = msg.value;
startTime = block.timestamp;
active = true;
emit ContractCreated(renter, provider, dataSize);
}
function fulfillContract() external {
require(msg.sender == provider, "Only provider can fulfill");
require(block.timestamp >= startTime + duration, "Contract not yet complete");
require(active, "Contract no longer active");
active = false;
payable(provider).transfer(price);
emit ContractFulfilled(renter, provider);
}
// Additional functions for disputes, early termination, etc.
}S