Storage Terms - joint currency and pricing configuration

Open
#627 3 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@Kubuxu is already working on this.

Since Oct 19, 2026.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
8/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
solidity

Research direction

This is a design proposal with open questions, not a task with a defined edit. Start by reading the feat/storage-terms branch and the proposal's open question on whether CreateDataSetWithStorageTerms needs its own SessionKeyRegistry scope. Done means the design decisions are settled by maintainers before any code is written.

Written by the indexing model from the issue text.

Description

Supersedes #618 and #619.

Aim

Allow contract owners to add different currency and pricing terms without introducing the complexity of full configurability.

How

This proposal combines currency and pricing configuration into Storage Terms.
Storage Terms can be added by the contract owner and allow for creation of new datasets under these terms.
The terms currently consist of:

struct StorageTerms {
    address token; // address of the token to be used
    uint8 tokenDecimals; // decimals of the token used by these terms
    uint256 pricePerTiBPerMonth; // price per TiB per month in the token's smallest units
    bytes32 salt; // additional salt allowing for separation of terms
}

The salt exists so StorageTerms with identical pricing can be differentiated. A client can specify them in their dataset creation request and a storage provider can accept or refuse them.

They are identified by their hash:

bytes32 storageTermsId = keccak256(
    abi.encode(
        keccak256("filecoin.FWSS.StorageTerms.v1"),
        terms.token,
        terms.tokenDecimals,
        terms.pricePerTiBPerMonth,
        terms.salt
    )
);

For now, the system design considers USD stablecoins. This narrowing of scope exists because the fees are not configurable. Token decimals are verified during registration.

The definition is immutable. The owner can disable terms for new datasets and re-enable them by registering the same terms again.
Disabling only prevents new datasets from selecting the terms. It does not interrupt payments or other operations on existing datasets. A dataset cannot switch terms after creation.

After the contract owner registers terms using registerStorageTerms(StorageTerms) returns (bytes32 storageTermsId),
new datasets can be created using them via a new variant of signed extraData:

abi.encode(payer, clientDataSetId, keys, values, signature, storageTermsId)

The new EIP-712 type is:
CreateDataSetWithStorageTerms(uint256 clientDataSetId,address payee,MetadataEntry[] metadata,bytes32 storageTermsId)MetadataEntry(string key,string value)

Storage Terms are stored in the ERC-7201 namespace filecoin.FWSS.StorageTerms, rooted at:

// keccak256(abi.encode(uint256(keccak256("filecoin.FWSS.StorageTerms")) - 1)) & ~bytes32(uint256(0xff))
bytes32 constant STORAGE_TERMS_STORAGE_LOCATION =
    0xffe2107a587f9a58b0aaa87110a43c1dc6de9e3d39b63f9be37b80538b60ff00;

It stores a map of:

mapping(bytes32 storageTermsId => StorageTermsRecord) storageTerms;

struct StorageTermsRecord {
    address token;
    uint8 tokenDecimals;
    uint8 version;
    bool enabled;
    uint256 pricePerTiBPerMonth;
    bytes32 salt;
}

Each record occupies three consecutive slots. version is the terms schema version, not a revision of an individual definition. It is currently 1 for registered terms; 0 marks an unregistered entry.

In the current prototype datasets requesting FilBeam and a non-default currency are rejected.
This prototype uses an additional SessionKeyRegistry scope for CreateDataSetWithStorageTerms, although I'm still not sure about introducing it.

Backwards compatibility

The storageTermsId of each dataset is stored in DataSetInfo at relative slot 11, added to the end.
For existing datasets it will be zero, defaulting to the terms identified by legacyStorageTermsId().
This ID uses the hash formula above with (address(usdfcTokenAddress), uint8(18), uint256(2.5e18), bytes32(0)),
corresponding to the existing configuration: USDFC, 18 decimals, 2.5 USDFC/TiB/month, and zero salt.
The literal ID depends on the deployment's USDFC token address.

The old extraData format also selects these legacy terms. The new format requires an explicit, nonzero terms ID.
Legacy terms can be explicitly registered, but cannot be disabled in the current prototype.

Open questions

Should the new request require a separate SessionKeyRegistry scope, or reuse the existing creation scope? A separate scope avoids expanding existing grants to additional currencies and prices, but requires clients to grant another permission.


Branch feat/storage-terms contains a very early draft of the idea.

Dominant language
Solidity
Stars
8
Forks
27
Avg merge
2d 5h
Merged PRs (30d)
12

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from FilOzone/filecoin-services

All issues in FilOzone/filecoin-services

Similar issues

More Security issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.