Learn how to tip an IP Asset using the SDK and Smart Contracts.
In this tutorial, you will learn how to send money (“tip”) an IP Asset using the TypeScript SDK.
In this scenario, let’s say there is a parent IP Asset that represents Mickey Mouse. Someone else draws a hat on that Mickey Mouse and registers it as a derivative (or “child”) IP Asset. The License Terms specify that the child must share 50% of all commercial revenue (commercialRevShare = 50
) with the parent. Someone else (a 3rd party user) comes along and wants to send the derivative 2 $WIP for being really cool.
For the purposes of this example, we will assume the child is already registered as a derivative IP Asset. If you want help learning this, check out Register a Derivative.
0x42595dA29B541770D9F9f298a014bF912655E183
0xeaa4Eed346373805B377F5a4fe1daeFeFB3D182a
There are a few steps you have to complete before you can start the tutorial.
.env
file:.env
file. You can just use the public default one we provide:In a utils.ts
file, add the following code to set up your Story Config:
Now create a main.ts
file. We will use the payRoyaltyOnBehalf
function to pay the derivative asset.
You will be paying the IP Asset with $WIP. Note that if you don’t have enough $WIP, the function will auto wrap an equivalent amount of $IP into $WIP for you. If you don’t have enough of either, it will fail.
Whitelisted Revenue Tokens
Only tokens that are whitelisted by our protocol can be used as payment (“revenue”) tokens. $WIP is one of those tokens. To see that list, go here.
Now we can call the payRoyaltyOnBehalf
function. In this case:
receiverIpId
is the ipId
of the derivative (child) assetpayerIpId
is zeroAddress
because the payer is a 3rd party (someone that thinks Mickey Mouse with a hat on him is cool), and not necessarily another IP Assettoken
is the address of $WIP, which can be found hereamount
is 2, since the person tipping wants to send 2 $WIPAt this point we have already finished the tutorial: we learned how to tip an IP Asset. But what if the child and parent want to claim their due revenue?
The child has been paid 2 $WIP. But remember, it shares 50% of its revenue with the parent IP because of the commercialRevenue = 50
in the license terms.
The child IP can claim its 1 $WIP by calling the claimAllRevenue
function:
ancestorIpId
is the ipId
we’re claiming revenue forcurrencyTokens
is an array that contains the address of $WIP, which can be found hereclaimer
is the address that holds the royalty tokens associated with the child’s IP Royalty Vault. By default, they are in the IP Account, which is just the ipId
of the child asset.Claiming revenue is permissionless. Any wallet can run the claim revenue transaction for an IP.
Continuing, the parent should be able to claim its revenue as well. In this example, the parent should be able to claim 1 $WIP since the child earned 2 $WIP and the commercialRevShare = 50
in the license terms.
We will use the claimAllRevenue
function to claim the due revenue tokens.
ancestorIpId
is the ipId
of the parent (“ancestor”) assetclaimer
is the address that holds the royalty tokens associated with the parent’s IP Royalty Vault. By default, they are in the IP Account, which is just the ipId
of the parent assetchildIpIds
will have the ipId
of the child assetroyaltyPolicies
will contain the address of the royalty policy. As explained in Royalty Module, this is either RoyaltyPolicyLAP
or RoyaltyPolicyLRP
, depending on the license terms. In this case, let’s assume the license terms specify a RoyaltyPolicyLAP
. Simply go to Deployed Smart Contracts and find the correct address.currencyTokens
is an array that contains the address of $WIP, which can be found hereClaiming revenue is permissionless. Any wallet can run the claim revenue transaction for an IP.
A couple of things to note here:
By default, revenue is claimed to the IP Account, not the IP owner’s wallet. This is because when an IP is created, the royalty tokens for that IP (where revenue gets claimed to) are minted to the IP Account.
To transfer revenue from IP Account -> IP Owner’s wallet, an IP owner can
run the transferErc20
function (it will not work
if you run it for someone else’s IP obviously).
If the IP owner (the wallet that owns the underlying IP ownership NFT) had
called claimAllRevenue
before, our SDK would automatically transfer the revenue
to the IP owner’s wallet for convenience.
If the IP owner wants revenue to always be claimed to their wallet and avoid the middle step, they should transfer the royalty tokens from the IP account to their wallet.