Datatoken Templates
Discover all about the extensible & flexible smart contract templates.
Last updated
Was this helpful?
Discover all about the extensible & flexible smart contract templates.
Last updated
Was this helpful?
Each or within Ocean Protocol is generated from pre-defined contracts. The templateId parameter specifies the template used for creating a data NFT or datatoken, which can be set during the creation process. The templateId is stored within the smart contract code and can be accessed using the () function.
Currently, Ocean Protocol supports 1 type for data NFTs and 2 template variants for datatokens: the and the . While these templates share the same interfaces, they differ in their underlying implementation and may offer additional features.
The details regarding currently supported datatoken templates are as follows:
The regular template allows users to buy/sell/hold datatokens. The datatokens can be minted by the address having a role, making the supply of datatoken variable. This template is assigned templateId =
1
and the source code is available .
The enterprise template has additional functions apart from methods in the ERC20 interface. This additional feature allows access to the service by paying in the basetoken instead of the datatoken. Internally, the smart contract handles the conversion of basetoken to datatoken, initiating an order to access the service, and minting/burning the datatoken. The total supply of the datatoken effectively remains 0 in the case of the enterprise template. This template is assigned templateId =
2
and the source code is available .
When you're creating an ERC20 datatoken, you can specify the desired template by passing on the template index.
To specify the datatoken template via ocean.js, you need to customize the with your desired templateIndex
.
The default template used is 1.
To identify the template used for a specific asset, you can easily retrieve this information using the network explorer. Here are the steps to follow:
Visit the network explorer where the asset was published.
Once you have located the datatoken address, click on the contract tab to access more details.
Within the contract details, we can identify and determine the template used for the asset.
Search for the datatoken address
We like making things easy so here is an even easier way to retrieve the info for asset published in the Ocean Market: