The permissions governing access to the smart contract functions are stored within the data NFT (ERC721) smart contract. Both the data NFT (ERC721) and datatoken (ERC20) smart contracts utilize this information to enforce restrictions on certain actions, limiting access to authorized users. The tables below outline the specific actions that are restricted and can only be accessed by allowed users.
The data NFT serves as the foundational intellectual property (IP) for the asset, and all datatokens are inherently linked to the data NFT smart contract. This linkage has enabled the introduction of various exciting capabilities related to role administration.
NFT Owner
The NFT owner is the owner of the base-IP and is therefore at the highest level. The NFT owner can perform any action or assign any role but crucially, the NFT owner is the only one who can assign the manager role. Upon deployment or transfer of the data NFT, the NFT owner is automatically added as a manager. The NFT owner is also the only role that can’t be assigned to multiple users — the only way to share this role is via multi-sig or a DAO.
Roles-NFT level
With the exception of the NFT owner role, all other roles can be assigned to multiple users.
There are several methods available to assign roles and permissions. One option is to utilize the ocean.py and ocean.js libraries that we provide. These libraries offer a streamlined approach for assigning roles and permissions programmatically.
Alternatively, for a more straightforward solution that doesn't require coding, you can utilize the network explorer of your asset's network. By accessing the network explorer, you can directly interact with the contracts associated with your asset. Below, we provide a few examples to help guide you through the process.
Manager
The ability to add or remove Managers is exclusive to the NFT Owner. If you are the NFT Owner and wish to add/remove a new manager, simply call the addManager/removeManager function within the ERC721Template contract. This function enables you to grant managerial permissions to the designated individual.
Add/Remove Manager Contract functions
/*** @dev addManager* Only NFT Owner can add a new manager (Roles admin)* There can be multiple minters* @param _managerAddress new manager address*/functionaddManager(address_managerAddress) externalonlyNFTOwner {_addManager(_managerAddress);}/*** @dev removeManager* Only NFT Owner can remove a manager (Roles admin)* There can be multiple minters* @param _managerAddress new manager address*/functionremoveManager(address_managerAddress) externalonlyNFTOwner {_removeManager(_managerAddress);}
The manager can assign or revoke three main roles (deployer, metadata updater, and store updater). The manager is also able to call any other contract (ERC725X implementation).
Metadata Updater
There is also a specific role for updating the metadata. The Metadata updater has the ability to update the information about the data asset (title, description, sample data etc) that is displayed to the user on the asset detail page within the market.
/*** @dev addToMetadataList* Adds metadata role to an user.* It can be called only by a manager* @param _allowedAddress user address*/functionaddToMetadataList(address_allowedAddress) publiconlyManager {_addToMetadataList(_allowedAddress);}/*** @dev removeFromMetadataList* Removes metadata role from an user.* It can be called by a manager or by the same user, if he already has metadata role* @param _allowedAddress user address*/functionremoveFromMetadataList(address_allowedAddress) public {if(permissions[msg.sender].manager ==true|| (msg.sender == _allowedAddress && permissions[msg.sender].updateMetadata ==true) ){ Roles storage user = permissions[_allowedAddress]; user.updateMetadata =false; emitRemovedFromMetadataList(_allowedAddress,msg.sender,block.timestamp,block.number);_SafeRemoveFromAuth(_allowedAddress); }else{revert("ERC721RolesAddress: Not enough permissions to remove from metadata list"); }}
Store Updater
The store updater can store, remove or update any arbitrary key value using the ERC725Y implementation (at the ERC721 level). The use case for this role depends a lot on what data is being stored in the ERC725Y key-value pair — as mentioned above, this is highly flexible.
/*** @dev addTo725StoreList* Adds store role to an user.* It can be called only by a manager* @param _allowedAddress user address*/functionaddTo725StoreList(address_allowedAddress) publiconlyManager {if(_allowedAddress !=address(0)){ Roles storage user = permissions[_allowedAddress]; user.store =true;_pushToAuth(_allowedAddress);emitAddedTo725StoreList(_allowedAddress,msg.sender,block.timestamp,block.number); }}/*** @dev removeFrom725StoreList* Removes store role from an user.* It can be called by a manager or by the same user, if he already has store role* @param _allowedAddress user address*/functionremoveFrom725StoreList(address_allowedAddress) public {if(permissions[msg.sender].manager ==true|| (msg.sender == _allowedAddress && permissions[msg.sender].store ==true) ){ Roles storage user = permissions[_allowedAddress]; user.store =false;emitRemovedFrom725StoreList(_allowedAddress,msg.sender,block.timestamp,block.number);_SafeRemoveFromAuth(_allowedAddress); }else{revert("ERC721RolesAddress: Not enough permissions to remove from 725StoreList"); }}
ERC20 Deployer
The Deployer has a bunch of privileges at the ERC20 datatoken level. They can deploy new datatokens with fixed price exchange, or free pricing. They can also update the ERC725Y key-value store and assignroles at the ERC20 level(datatoken level).
/*** @dev addToCreateERC20List* Adds deployERC20 role to an user.* It can be called only by a manager* @param _allowedAddress user address*/functionaddToCreateERC20List(address_allowedAddress) publiconlyManager {_addToCreateERC20List(_allowedAddress);}/*** @dev removeFromCreateERC20List* Removes deployERC20 role from an user.* It can be called by a manager or by the same user, if he already has deployERC20 role* @param _allowedAddress user address*/functionremoveFromCreateERC20List(address_allowedAddress) public {if(permissions[msg.sender].manager ==true|| (msg.sender == _allowedAddress && permissions[msg.sender].deployERC20 ==true) ){ Roles storage user = permissions[_allowedAddress]; user.deployERC20 =false;emitRemovedFromCreateERC20List(_allowedAddress,msg.sender,block.timestamp,block.number);_SafeRemoveFromAuth(_allowedAddress); }else{revert("ERC721RolesAddress: Not enough permissions to remove from ERC20List"); }}
To assign/remove all the above roles(ERC20 Deployer, Metadata Updater, or Store Updater), the manager can use the addMultipleUsersToRoles function from the ERC721RolesAddress.
Roles & permissions in data NFT (ERC721) smart contract
Action ↓ / Role →
NFT Owner
Manager
ERC20 Deployer
Store Updater
Metadata Updater
Set token URI
Add manager
✓
Remove manager
✓
Clean permissions
✓
Set base URI
✓
Set Metadata state
✓
Set Metadata
✓
Create new datatoken
✓
Executes any other smart contract
✓
Set new key-value in store
✓
Roles-datatokens level
Minter
The Minter has the ability to mint new datatokens, provided the limit has not been exceeded.
To add/remove a minter, the ERC20 deployer can use the addMinter/removeMinter functions from the ERC20Template.
Add/Remove Minter Contract functions
/*** @dev addMinter* Only ERC20Deployer (at 721 level) can update.* There can be multiple minters* @param _minter new minter address*/functionaddMinter(address_minter) externalonlyERC20Deployer {_addMinter(_minter);}/*** @dev removeMinter* Only ERC20Deployer (at 721 level) can update.* There can be multiple minters* @param _minter minter address to remove*/functionremoveMinter(address_minter) externalonlyERC20Deployer {_removeMinter(_minter);}
Fee Manager
Finally, we also have a fee manager which has the ability to set a new fee collector — this is the account that will receive the datatokens when a data asset is consumed. If no fee collector account has been set, the datatokens will be sent by default to the NFT Owner.
The applicable fees (market and community fees) are automatically deducted from the datatokens that are received.
/*** @dev addPaymentManager (can set who's going to collect fee when consuming orders)* Only ERC20Deployer (at 721 level) can update.* There can be multiple paymentCollectors* @param _paymentManager new minter address*/functionaddPaymentManager(address_paymentManager) externalonlyERC20Deployer{_addPaymentManager(_paymentManager);}/*** @dev removePaymentManager* Only ERC20Deployer (at 721 level) can update.* There can be multiple paymentManagers* @param _paymentManager _paymentManager address to remove*/functionremovePaymentManager(address_paymentManager) externalonlyERC20Deployer{_removePaymentManager(_paymentManager);}
When the NFT ownership is transferred to another wallet address, all the roles and permissions and cleared.
functioncleanPermissions() externalonlyNFTOwner {_cleanPermissions();//Make sure that owner still has permissions_addManager(ownerOf(1));}
Roles & permission in datatoken (ERC20) smart contract