Introduction to Royalty Management on Smart Contracts
This is the boilerplate smart contract library showcasing transparent royalty management and royalty distribution through smart contracts. It is applicable for most of the digital products, with the triggering of royalty distribution happening upon every purchase or consumption of the digital product.
DISCLAIMER: THIS SMART CONTRACT SUITE WAS DESIGNED FOR DEMO PURPOSES; UNLESS EXPLICITLY INDICATED OTHERWISE, THESE SMART CONTRACTS HAVE NOT BEEN AUDITED FOR PRODUCTION USAGE.
dRoyalty Smart Contract Components
Management is a base smart contract which manages references and permissions of other smart contracts. Its basic functionality includes:
- registerContract(uint256 _key, address _target) – register _target contract to specified _key
- setPermission(address _address, uint256 _permission, bool _value) – set or unset _permission to make some actions for _address
And other functions allowing to manage and check state variables.
Managed – a parent contract for platform-related smart contracts, except Management. It is aimed at keeping the actual Management contract address and interacting with all other contracts through the Management contract.
Constants is a contract designed for storing constants indicating contracts and their permission to perform certain actions.
Royalty is the ERC-721-based smart contract extended with DigitalAsset structure to store additional info for an asset. It has a function to create/register a new asset. It emits a DigitalAssetRegistered event.
Asset Purchase is a smart contract that receives ethers to buy the license for the exact asset (it has the function called purchaseDigitalAsset(uint256 _digitalAssetId) and emits event (interacts with royalty through management):
uint256 indexed digitalAssetId,
address indexed buyer,
); to prove license buying.
Cashier is a smart contract responsible for managing funds flowing through the platform. Within it, function recordPurchase(uint256 _digitalAssetId) public payable – receives and transfers ethers to asset owner and platform-related address from Asset Purchase contract paid to buy a license; function forwardEthersToHolder() public payable – receives and transfers ethers from Royalty contract paid to register new asset.
Use Flow and Roles
There are five main roles (the ether address of the user) which interact with smart contract:
- Platform-related Ethereum address to sign a transaction.
- Owner address of the platform – can manage contracts and state variables.
- Platform revenue holder address – receives all the Ethers earned by the platform.
- Digital assets owner – receives royalty.
- Digital assets license’s buyer address.
Screenshots of Interaction with Smart Contracts
To create new Digital Asset property the owner needs to transfer Ethers amount equal to registration fee among with hash data to Royalty contract address:
The hash data contains createDigitalAssets functions with signed sender address, registration fee amount, URI and the current timestamp:
When a transaction is successful the new token will be created:
Using ID and price of needed asset the buyer has to run function purchaseDigitalAsset of AssetPurchase contract.
The proof of license is event.