Register an IP Asset
Learn how to Register an NFT as an IP Asset in Solidity.
Completed Code
Follow the completed code all the way through.
Let’s say you have some off-chain IP (ex. a book, a character, a drawing, etc). In order to register that IP on Story, you first need to mint an NFT. This NFT is the ownership over the IP. Then you register that NFT on Story, turning it into an IP Asset. The below tutorial will walk you through how to do this.
Prerequisites
There are a few steps you have to complete before you can start the tutorial.
- Complete the Setup Your Own Project
Before We Start
There are two scenarios:
- You already have a custom ERC-721 NFT contract and can mint from it
- You want to create an SPG (Periphery) NFT contract to do minting for you
Scenario #1: You already have a custom ERC-721 NFT contract and can mint from it
If you already have an NFT minted, or you want to register IP using a custom-built ERC-721 contract, this is the section for you.
As you can see below, the registration process is relatively straightforward. We use SimpleNFT
as an example, but you can replace it with your own ERC-721 contract.
All you have to do is call register
on the IP Asset Registry with:
chainid
- you can simply useblock.chainid
tokenContract
- the address of your NFT collectiontokenId
- your NFT’s ID
Let’s create a test file under test/0_IPARegistrar.t.sol
to see it work and verify the results:
Contract Addresses
We have filled in the addresses from the Story contracts for you. However you can also find the addresses for them here: Deployed Smart Contracts
You can view the SimpleNFT
contract we’re using to test here.
You can view the SimpleNFT
contract we’re using to test here.
Scenario #2: You want to create an SPG NFT contract to do minting for you
If you don’t have your own custom NFT contract, this is the section for you.
To achieve this, we will be using the SPG, which is a utility contract that allows us to combine multiple transactions into one. In this case, we’ll be using the SPG’s mintAndRegisterIp
function which combines both minting an NFT and registering it as an IP Asset.
In order to use mintAndRegisterIp
, we first have to create a new SPGNFT
collection. We can do this simply by calling createCollection
on the StoryProtocolGateway
contract. Or, if you want to create your own SPGNFT
for some reason, you can implement the ISPGNFT contract interface. Follow the example below to see example parameters you can use to initialize a new SPGNFT.
Once you have your own SPGNFT, all you have to do is call mintAndRegisterIp
with:
spgNftContract
- the address of your SPGNFT contractrecipient
- the address of who will receive the NFT and thus be the owner of the newly registered IP. Note: remember that registering IP on Story is permissionless, so you can register an IP for someone else (by paying for the transaction) yet they can still be the owner of that IP Asset.ipMetadata
- the metadata associated with your NFT & IP. See this section to better understand setting NFT & IP metadata.
- Run
touch test/0_IPARegistrar.t.sol
to create a test file undertest/0_IPARegistrar.t.sol
. Then, paste in the following code:
Contract Addresses
We have filled in the addresses from the Story contracts for you. However you can also find the addresses for them here: Deployed Smart Contracts
Run the Test and Verify the Results
-
Run
forge build
. If everything is successful, the command should successfully compile. -
Now run the test by executing the following command:
Add License Terms to IP
Congratulations, you registered an IP!
Completed Code
Follow the completed code all the way through.
Now that your IP is registered, you can create and attach License Terms to it. This will allow others to mint a license and use your IP, restricted by the terms.
We will go over this on the next page.