Skip to main content

Completed Code

See the completed code.

Video Walkthrough

Check out a video walkthrough of this tutorial!

Writing the Smart Contract

Now that we have walked through each of the individual steps, let’s try to write, deploy, and verify our own smart contract.

Register IPA, Register License Terms, and Attach to IPA

In this first section, we will combine a few of the tutorials into one. We will create a function named mintAndRegisterAndCreateTermsAndAttach that allows you to mint & register a new IP Asset, register new License Terms, and attach those terms to an IP Asset. It will also accept a receiver field to be the owner of the new IP Asset.

Prerequisites

Writing Our Contract

Create a new file under ./src/Example.sol and paste the following:
Contract AddressesIn order to get the contract addresses to pass in the constructor, go to Deployed Smart Contracts.
src/Example.sol

Mint a License Token and Register as Derivative

In this next section, we will combine a few of the later tutorials into one. We will create a function named mintLicenseTokenAndRegisterDerivative that allows a potentially different user to register their own “child” (derivative) IP Asset, mint a License Token from the “parent” (root) IP Asset, and register their child IPA as a derivative of the parent IPA. It will accept a few parameters:
  1. parentIpId: the ipId of the parent IPA
  2. licenseTermsId: the id of the License Terms you want to mint a License Token for
  3. receiver: the owner of the child IPA

Prerequisites

Writing Our Contract

In your Example.sol contract, add the following function at the bottom:
src/Example.sol

Testing Our Contract

Create another new file under test/Example.t.sol and paste the following:
test/Example.t.sol
Run forge build. If everything is successful, the command should successfully compile. To test this out, simply run the following command:

Deploy & Verify the Example Contract

The --constructor-args come from Deployed Smart Contracts.
If everything worked correctly, you should see something like Deployed to: 0xfb0923D531C1ca54AB9ee10CB8364b23d0C7F47d in the console. Paste that address into the explorer and see your verified contract!

Great job! :)

Completed Code

See the completed code.

Video Walkthrough

Check out a video walkthrough of this tutorial!