Learn how to Register an NFT as an IP Asset in Solidity.
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 collectiontokenId
- your NFT’s IDtest/0_IPARegistrar.t.sol
to see it work and verify the results:
SimpleNFT
contract we’re using to test here.SimpleNFT
contract we’re using to test here.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.touch test/0_IPARegistrar.t.sol
to create a test file under test/0_IPARegistrar.t.sol
. Then, paste in the following code:forge build
. If everything is successful, the command should successfully compile.