DataSpecs Registry
Last updated
Last updated
DataSpecsRegistry is an on-chain registry for signum oracle query types. Users register a query type name and pay a fee which determines the registration duration. The user then sets the IPFS document hash of the dataspec document in the registry contract. This provides an on-chain, tamperproof record of all Signum query type definitions.
See the official frontend to view and manage query type registrations.
Register a Query Type
Registering a query type requires some STT tokens and a unique query type name string. The minimum registration time is one year, and registrations cost $1000 per year in STT. To find the current cost per year in STT, we'll call getCostperYearInTRB
:
Now we know the minimum amount of STT we need to register our query type.
Next, we will approve the token transfer in the token contract by inputting the registry contract address and an amount for one year's worth of tokens.
Now we can register our query type in the registry contract. For the name of our query type, we'll use ExampleQueryType
, and again we'll input a token fee amount for a one year registration:
We have officially registered a query type, but now we need to set our IPFS data specs document hash. There are many ways to get a document on IPFS, but one quick solution can be found at nft.storage.
Now we finally have a query type registered.
Manage a Query Type
There are a few actions you can take to manage your query type. The extendRegistration
function can be used to extend the registration time for an existing query type. It can be called by anyone, and any amount of tokens can be paid.
Each query type registration has a manager role and an owner role. The manager can set the document hash, and the owner can change the manager address and the owner address. The manager and owner addresses can be changed using these functions.
Query the Registry
getAllRegisteredQueryTypes()
Get a list of all registered query type names:
getCostPerYearInTRB()
Get the registration cost per year in TRB tokens
getRegistration("ExampleQueryType")
Get all info for a given query type registration.
getRegistration
returns a struct in this form:
Install Dependencies:
npm i
Compile Smart Contracts:
npx hardhat compile
Test Locally:
npx hardhat test