Storage Contracts

Storage contracts in DÆTA define the agreements between users and storage providers, ensuring a decentralized and transparent relationship.

Storage contracts are smart contracts that govern the relationship between users (renters) and storage providers (nodes) on the DÆTA network.

Contract Lifecycle

state Diagram v2
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 --> [*]

Key Contract Parameters

Length of the storage agreement.

90 days.

Sample Contract

Simplified Solidity
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

Last updated