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 TypeScript SDK Setup
  2. [OPTIONAL] Go to Pinata and create a new API key. Add the JWT to your .env file:
.env
  1. [OPTIONAL] Install the pinata-web3 dependency:
Terminal

1. Set up Your IP Metadata

We can set metadata on our NFT & IP, but you don’t have to. To do this, view the IPA Metadata Standard and construct your metadata for both your NFT & IP.
main.ts

2. Set up Your NFT Metadata

The NFT Metadata follows the ERC-721 Metadata Standard.
main.ts

3. Upload Your IP and NFT Metadata to IPFS

In a separate uploadToIpfs file, create a function to upload your IP & NFT Metadata objects to IPFS:
uploadToIpfs.ts
You can then use that function to upload your metadata, as shown below:
main.ts

4. Register an NFT as an IP Asset

Remember that in order to register a new IP, we first have to mint an NFT, which will represent the underlying ownership of the IP. This NFT then gets “registered” and becomes an IP Asset. Luckily, we can use the registerIpAsset function to mint an NFT and register it as an IP Asset in the same transaction. This function needs an SPG NFT Contract to mint from.

4a. What SPG NFT contract address should I use?

For simplicity, you can use a public collection we have created for you on Aeneid testnet: 0xc32A8a0FF3beDDDa58393d022aF433e78739FAbc. On Mainnet, or even when testing a real scenario on Aeneid, you should create your own contract as described in the “Using a custom ERC-721 contract” section below.
Using a public collection we provide for you is fine, but when you do this for real, you should make your own NFT Collection for your IPs. You can do this in 2 ways:
  1. Deploy a contract that implements the ISPGNFT interface, or use the SDK’s createNFTCollection function (shown below) to do it for you. This will give you your own SPG NFT Collection that only you can mint from.
createSpgNftCollection.ts
  1. Create a custom ERC-721 NFT collection on your own. See a working code example here. This is helpful if you already have a custom NFT contract that has your own custom logic, or if your IPs themselves are NFTs.
Here is the code to register an IP:
Associated Docs: ipAsset.registerIpAsset
main.ts

5. Add License Terms to IP

During the registration process, you can attach License Terms to the IP. This will allow others to mint a license and use your IP, restricted by the terms.
main.ts

6. View Completed Code

Congratulations, you registered an IP and attached license terms to it!

Completed Code

Follow the completed code all the way through.