Skip to main content

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 the DATA Foundation, you first need to mint an NFT. This NFT is the ownership over the IP. Then you register that NFT on the DATA Foundation, 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.
  1. Complete the Setup Your Own Project

Before We Start

There are two scenarios:
  1. You already have a custom ERC-721 NFT contract and can mint from it
  2. 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 use block.chainid
  • tokenContract - the address of your NFT collection
  • tokenId - 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 AddressesWe have filled in the addresses from the DATA Foundation contracts for you. However you can also find the addresses for them here: Deployed Smart ContractsYou can view the SimpleNFT contract we’re using to test here.
You can view the SimpleNFT contract we’re using to test here.
test/0_IPARegistrar.t.sol

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 contract
  • recipient - the address of who will receive the NFT and thus be the owner of the newly registered IP. Note: remember that registering IP on the DATA Foundation 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.
  1. Run touch test/0_IPARegistrar.t.sol to create a test file under test/0_IPARegistrar.t.sol. Then, paste in the following code:
Contract AddressesWe have filled in the addresses from the DATA Foundation contracts for you. However you can also find the addresses for them here: Deployed Smart Contracts
test/0_IPARegistrar.t.sol

Run the Test and Verify the Results

  1. Run forge build. If everything is successful, the command should successfully compile.
  2. 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.