> ## Documentation Index
> Fetch the complete documentation index at: https://docs.story.foundation/llms.txt
> Use this file to discover all available pages before exploring further.

# IP Asset

> IPAsset allows you to create, get, and list IP Assets within Story.

## IPAsset

### Methods

* register
* register\_derivative
* register\_derivative\_with\_license\_tokens
* mint\_and\_register\_ip\_asset\_with\_pil\_terms

### Navigating Around the IPAssetClient

Because there are a lot of functions to interact with the [📜 Licensing Module](/concepts/licensing-module), we have broken them down into a helpful chart so you can identify what you're looking for, and then find the associated docs.

| **Function**                                                                             | **Mint an NFT** | **Register IPA** | **Create License Terms** | **Attach License Terms** | **Mint License Token** | **Register as Derivative** |
| ---------------------------------------------------------------------------------------- | :-------------: | :--------------: | :----------------------: | :----------------------: | :--------------------: | :------------------------: |
| <span style={{color: "#e03130"}}>register</span>                                         |                 |         ✓        |                          |                          |                        |                            |
| <span style={{color: "#e03130"}}>mint\_and\_register\_ip\_asset\_with\_pil\_terms</span> |        ✓        |         ✓        |             ✓            |             ✓            |                        |                            |
| <span style={{color: "#e03130"}}>register\_derivative</span>                             |                 |                  |                          |                          |                        |              ✓             |
| <span style={{color: "#e03130"}}>register\_derivative\_with\_license\_tokens</span>      |                 |                  |                          |                          |                        |              ✓             |
| <span style={{color: "#1971c2"}}>register\_pil\_terms</span>                             |                 |                  |             ✓            |                          |                        |                            |
| <span style={{color: "#1971c2"}}>attach\_license\_terms</span>                           |                 |                  |                          |             ✓            |                        |                            |
| <span style={{color: "#1971c2"}}>mint\_license\_tokens</span>                            |                 |                  |                          |                          |            ✓           |                            |

* <span style={{ color: "#e03130" }}>Red</span>: IPAssetClient (this page)
* <span style={{ color: "#1971c2" }}>Blue</span>:
  [LicenseClient](/sdk-reference/python/license)

## register

Registers an NFT as IP, creating a corresponding [🧩 IP Asset](/concepts/ip-asset). If the given NFT was already registered, this function will return the existing `ipId`.

<Note title="NFT Metadata">
  Note that this function will also set the underlying NFT's `tokenUri` to
  whatever is passed under `ipMetadata.nftMetadataURI`.
</Note>

| Method     |
| ---------- |
| `register` |

Parameters:

* `nft_contract`: The address of the NFT.
* `token_id`: The token identifier of the NFT.
* `ip_metadata`: \[Optional] The desired metadata for the newly minted NFT and newly registered IP.
  * `ip_metadata['ip_metadata_uri']`: \[Optional] The URI of the metadata for the IP.
  * `ip_metadata['ip_metadata_hash']`: \[Optional] The hash of the metadata for the IP.
  * `ip_metadata['nft_metadata_uri']`: \[Optional] The URI of the metadata for the NFT.
  * `ip_metadata['nft_metadata_hash']`: \[Optional] The hash of the metadata for the IP NFT.
* `deadline`: \[Optional] The deadline for the signature in milliseconds.
* `tx_options`: \[Optional] Transaction options dictionary.

<CodeGroup>
  ```python Python theme={null}
  metadata = {
    'ip_metadata_uri': "test-uri",
    'ip_metadata_hash': web3.to_hex(web3.keccak(text="test-ip-metadata-hash")),
    'nft_metadata_uri': "test-uri",
    'nft_metadata_hash': web3.to_hex(web3.keccak(text="test-nft-metadata-hash"))
  }

  response = story_client.IPAsset.register(
    nft_contract="0x041B4F29183317Fd352AE57e331154b73F8a1D73",
    token_id="12",
    ip_metadata=metadata
  )
  ```

  ```python Request Parameters theme={null}
  nft_contract: str  # The address of the NFT
  token_id: str  # The token identifier of the NFT
  ip_metadata: dict = None  # Optional: Metadata for the NFT and IP
  deadline: int = None  # Optional: The deadline for the signature in milliseconds
  tx_options: dict = None  # Optional: Transaction options
  ```

  ```python Response theme={null}
  {
    "ip_id": str,  # The IP ID of the registered IP
    "tx_hash": str  # The transaction hash
  }
  ```
</CodeGroup>

## register\_derivative

Registers a derivative directly with parent IP's license terms, without needing license tokens, and attaches the license terms of the parent IPs to the derivative IP.

The license terms must be attached to the parent IP before calling this function.

All IPs attached default license terms by default.

The derivative IP owner must be the caller or an authorized operator.

| Method                |
| --------------------- |
| `register_derivative` |

Parameters:

* `child_ip_id`: The derivative IP ID.
* `parent_ip_ids`: The parent IP IDs.
* `license_terms_ids`: The IDs of the license terms that the parent IP supports.
* `max_minting_fee`: \[Optional] The maximum minting fee that the caller is willing to pay. If set to 0, then there is no limit. **Default: 0**
* `max_revenue_share`: \[Optional] The maximum revenue share percentage agreed upon between a child and parent when a child is registering as derivative. Must be between 0 and 100. **Default: 100**
* `max_rts`: \[Optional] The maximum number of royalty tokens that can be distributed to the external royalty policies. Must be between 0 and 100,000,000. **Default: 100\_000\_000**
* `tx_options`: \[Optional] Transaction options dictionary.

<CodeGroup>
  ```python Python theme={null}
  response = story_client.IPAsset.register_derivative(
    child_ip_id="0xC92EC2f4c86458AFee7DD9EB5d8c57920BfCD0Ba",
    parent_ip_ids=["0xC92EC2f4c86458AFee7DD9EB5d8c57920BfCD0Ba"],
    license_terms_ids=["5"],
    max_minting_fee=0, # disabled
    max_rts=100_000_000, # default
    max_revenue_share=100 # default
  )
  ```

  ```python Request Parameters theme={null}
  child_ip_id: str  # The derivative IP ID
  parent_ip_ids: list  # The parent IP IDs
  license_terms_ids: list  # The IDs of the license terms that the parent IP supports
  max_minting_fee: int = 0  # Optional: The maximum minting fee the caller is willing to pay
  max_rts: int = 0  # Optional: The maximum number of royalty tokens
  max_revenue_share: int = 0  # Optional: The maximum revenue share percentage
  license_template: str = None  # Optional: The address of the license template
  tx_options: dict = None  # Optional: Transaction options
  ```

  ```python Response theme={null}
  {
    "tx_hash": str  # The transaction hash
  }
  ```
</CodeGroup>

## register\_derivative\_with\_license\_tokens

Registers a derivative with license tokens.

The derivative IP is registered with license tokens minted from the parent IP's license terms.

The license terms of the parent IPs issued with license tokens are attached to the derivative IP.

The caller must be the derivative IP owner or an authorized operator.

| Method                                    |
| ----------------------------------------- |
| `register_derivative_with_license_tokens` |

Parameters:

* `child_ip_id`: The derivative IP ID.
* `license_token_ids`: The IDs of the license tokens.
* `max_rts`: The maximum number of royalty tokens that can be distributed to the external royalty policies. Must be between 0 and 100,000,000. **Recommended for simplicity: 100\_000\_000**
* `tx_options`: \[Optional] Transaction options dictionary.

<CodeGroup>
  ```python Python theme={null}
  response = story_client.IPAsset.register_derivative_with_license_tokens(
    child_ip_id="0xC92EC2f4c86458AFee7DD9EB5d8c57920BfCD0Ba",
    license_token_ids=["5"],
    max_rts=100_000_000 # default
  )
  ```

  ```python Request Parameters theme={null}
  child_ip_id: str  # The derivative IP ID
  license_token_ids: list  # The IDs of the license tokens
  max_rts: int = 0  # Optional: The maximum number of royalty tokens
  tx_options: dict = None  # Optional: Transaction options
  ```

  ```python Response theme={null}
  {
    "tx_hash": str  # The transaction hash
  }
  ```
</CodeGroup>

## mint\_and\_register\_ip\_asset\_with\_pil\_terms

Mint an NFT from a collection, register it as an IP, attach metadata to the IP, and attach License Terms to the IP all in one function.

<Note>
  Note that this function will also set the underlying NFT's `tokenUri` to
  whatever is passed under `ipMetadata.nftMetadataURI`.
</Note>

| Method                                      |
| ------------------------------------------- |
| `mint_and_register_ip_asset_with_pil_terms` |

Parameters:

* `spg_nft_contract`: The address of the NFT collection.
* `terms`: The array of license terms to be attached. ⚠️ **This function will fail if you pass in an empty array.**
  * `terms[].terms`: The license terms data. See the Python example below for the structure.
  * `terms[].licensing_config`: \[Optional] The licensing configuration. See the Python example below for the structure.
* `allow_duplicates`: \[Optional] Set to true to allow minting IPs with the same NFT metadata. **Default: True**
* `ip_metadata`: \[Optional] The desired metadata for the newly minted NFT and newly registered IP.
  * `ip_metadata['ip_metadata_uri']`: \[Optional] The URI of the metadata for the IP.
  * `ip_metadata['ip_metadata_hash']`: \[Optional] The hash of the metadata for the IP.
  * `ip_metadata['nft_metadata_uri']`: \[Optional] The URI of the metadata for the NFT.
  * `ip_metadata['nft_metadata_hash']`: \[Optional] The hash of the metadata for the IP NFT.
* `recipient`: \[Optional] The address of the recipient of the minted NFT.
* `tx_options`: \[Optional] Transaction options dictionary.

<CodeGroup>
  ```python Python theme={null}
  commercial_remix_terms = {
    "transferable": True,
    "royalty_policy": "0xBe54FB168b3c982b7AaE60dB6CF75Bd8447b390E", # RoyaltyPolicyLAP address from https://docs.story.foundation/docs/deployed-smart-contracts
    "default_minting_fee": 0,
    "expiration": 0,
    "commercial_use": True,
    "commercial_attribution": True,
    "commercializer_checker": "0x0000000000000000000000000000000000000000",
    "commercializer_checker_data": "0x0000000000000000000000000000000000000000",
    "commercial_rev_share": 50,
    "commercial_rev_ceiling": 0,
    "derivatives_allowed": True,
    "derivatives_attribution": True,
    "derivatives_approval": False,
    "derivatives_reciprocal": True,
    "derivative_rev_ceiling": 0,
    "currency": "0x1514000000000000000000000000000000000000", # $WIP address from https://docs.story.foundation/docs/deployed-smart-contracts
    "uri": "",
  }

  licensing_config = {
    "is_set": False,
    "minting_fee": 0,
    "licensing_hook": "0x0000000000000000000000000000000000000000",
    "hook_data": "0x0000000000000000000000000000000000000000",
    "commercial_rev_share": 0,
    "disabled": False,
    "expect_minimum_group_reward_share": 0,
    "expect_group_reward_pool": "0x0000000000000000000000000000000000000000",
  }

  metadata = {
    'ip_metadata_uri': "test-uri",
    'ip_metadata_hash': web3.to_hex(web3.keccak(text="test-ip-metadata-hash")),
    'nft_metadata_uri': "test-uri",
    'nft_metadata_hash': web3.to_hex(web3.keccak(text="test-nft-metadata-hash"))
  }

  response = story_client.IPAsset.mint_and_register_ip_asset_with_pil_terms(
    spg_nft_contract="0xfE265a91dBe911db06999019228a678b86C04959",
    terms=[{
      "terms": commercial_remix_terms,
      "licensing_config": licensing_config
    }],
    allow_duplicates=True,
    ip_metadata=metadata
  )
  ```

  ```python Request Parameters theme={null}
  spg_nft_contract: str  # The address of the NFT collection
  terms: list  # The array of license terms to be attached
  ip_metadata: dict = None  # Optional: Metadata for the NFT and IP
  recipient: str = None  # Optional: The address of the recipient of the minted NFT
  allow_duplicates: bool = False  # Optional: Allow minting IPs with the same NFT metadata
  tx_options: dict = None  # Optional: Transaction options
  ```

  ```python Response theme={null}
  {
    "ip_id": str,  # The IP ID of the registered IP
    "token_id": int,  # The token ID of the minted NFT
    "tx_hash": str,  # The transaction hash
    "license_terms_ids": list  # The IDs of the registered license terms
  }
  ```
</CodeGroup>
