> ## 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.

# Group

> Group allows you to create groups and add IP Assets to them.

## Group

### Methods

* register\_group
* register\_group\_and\_attach\_license
* mint\_and\_register\_ip\_and\_attach\_license\_and\_add\_to\_group
* register\_ip\_and\_attach\_license\_and\_add\_to\_group
* register\_group\_and\_attach\_license\_and\_add\_ips
* collect\_and\_distribute\_group\_royalties

### register\_group

Registers a Group IPA.

| Method           |
| ---------------- |
| `register_group` |

Parameters:

* `group_pool`: The address of the group pool.
* `tx_options`: \[Optional] The transaction options dictionary.

<CodeGroup>
  ```python Python theme={null}
  result = story_client.Group.register_group(
      group_pool="0xf96f2c30b41Cb6e0290de43C8528ae83d4f33F89",  # EvenSplitGroupPool
  )
  print(f"Group registered with ID: {result['group_id']} at transaction hash {result['tx_hash']}")
  ```

  ```python Request Parameters theme={null}
  group_pool: str  # The address of the group pool
  tx_options: dict = None  # Optional: Transaction options
  ```

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

### register\_group\_and\_attach\_license

Register a group IP with a group reward pool and attach license terms to the group IP.

| Method                              |
| ----------------------------------- |
| `register_group_and_attach_license` |

Parameters:

* `group_pool`: The address of the group pool.
* `license_data`: License data object with terms and config.
* `tx_options`: \[Optional] The transaction options dictionary.

<CodeGroup>
  ```python Python theme={null}
  result = story_client.Group.register_group_and_attach_license(
      group_pool="0xf96f2c30b41Cb6e0290de43C8528ae83d4f33F89",  # EvenSplitGroupPool
      license_data={
          "license_template": "0x7e9b9B31BF5F3399D36E1E0a9E589c30Cb6925D1",  # Programmable IP License
          "license_terms_id": "5"
      }
  )
  print(f"Group registered with ID: {result['group_id']} at transaction hash {result['tx_hash']}")
  ```

  ```python Request Parameters theme={null}
  group_pool: str  # The address of the group pool
  license_data: dict  # License data object with terms and config
  tx_options: dict = None  # Optional: Transaction options
  ```

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

### mint\_and\_register\_ip\_and\_attach\_license\_and\_add\_to\_group

Mint an NFT from a SPGNFT collection, register it with metadata as an IP, attach license terms to the registered IP, and add it to a group IP.

| Method                                                     |
| ---------------------------------------------------------- |
| `mint_and_register_ip_and_attach_license_and_add_to_group` |

Parameters:

* `group_id`: The ID of the group to add the IP to.
* `spg_nft_contract`: The address of the SPG NFT contract.
* `license_data`: List of license data objects with terms and config.
* `max_allowed_reward_share`: Maximum allowed reward share percentage.
* `ip_metadata`: \[Optional] The metadata for the IP.
* `recipient`: \[Optional] The recipient of the NFT (defaults to caller).
* `allow_duplicates`: \[Optional] Whether to allow duplicate IPs.
* `deadline`: \[Optional] The deadline for the signature in milliseconds.
* `tx_options`: \[Optional] The transaction options dictionary.

<CodeGroup>
  ```python Python theme={null}
  result = story_client.Group.mint_and_register_ip_and_attach_license_and_add_to_group(
      group_id="0x089d75C9b7E441dA3115AF93FF9A855BDdbfe384",
      spg_nft_contract="0x1234567890123456789012345678901234567890",
      license_data=[
          {
              "license_template": "0x7e9b9B31BF5F3399D36E1E0a9E589c30Cb6925D1",  # Programmable IP License
              "license_terms_id": "5"
          }
      ],
      max_allowed_reward_share=5,  # 5%
      ip_metadata={
          "ip_metadata_uri": "ipfs://QmXxxx",
          "ip_metadata_hash": "0x1234..."
      },
  )
  print(f"IP registered with ID: {result['ip_id']} and token ID: {result['token_id']} at transaction hash {result['tx_hash']}")
  ```

  ```python Request Parameters theme={null}
  group_id: str  # The ID of the group to add the IP to
  spg_nft_contract: str  # The address of the SPG NFT contract
  license_data: list  # List of license data objects with terms and config
  max_allowed_reward_share: int  # Maximum allowed reward share percentage
  ip_metadata: dict = None  # Optional: The metadata for the IP
  recipient: str = None  # Optional: The recipient of the NFT (defaults to caller)
  allow_duplicates: bool = True  # Optional: Whether to allow duplicate IPs
  deadline: int = None  # Optional: The deadline for the signature in milliseconds
  tx_options: dict = None  # Optional: Transaction options
  ```

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

### register\_ip\_and\_attach\_license\_and\_add\_to\_group

Register an NFT as IP with metadata, attach license terms to the registered IP, and add it to a group IP.

| Method                                            |
| ------------------------------------------------- |
| `register_ip_and_attach_license_and_add_to_group` |

Parameters:

* `group_id`: The ID of the group to add the IP to.
* `nft_contract`: The address of the NFT contract.
* `token_id`: The token ID of the NFT.
* `license_data`: List of license data objects with terms and config.
* `max_allowed_reward_share`: Maximum allowed reward share percentage.
* `ip_metadata`: \[Optional] The metadata for the IP.
* `deadline`: \[Optional] The deadline for the signature in milliseconds.
* `tx_options`: \[Optional] The transaction options dictionary.

<CodeGroup>
  ```python Python theme={null}
  result = story_client.Group.register_ip_and_attach_license_and_add_to_group(
      group_id="0x089d75C9b7E441dA3115AF93FF9A855BDdbfe384",
      nft_contract="0x1234567890123456789012345678901234567890",
      token_id=123,
      license_data=[
          {
              "license_template": "0x7e9b9B31BF5F3399D36E1E0a9E589c30Cb6925D1",  # Programmable IP License
              "license_terms_id": "5"
          }
      ],
      max_allowed_reward_share=5,  # 5%
      ip_metadata={
          "ip_metadata_uri": "ipfs://QmXxxx",
          "ip_metadata_hash": "0x1234..."
      }
  )
  print(f"IP registered with ID: {result['ip_id']} and token ID: {result['token_id']} at transaction hash {result['tx_hash']}")
  ```

  ```python Request Parameters theme={null}
  group_id: str  # The ID of the group to add the IP to
  nft_contract: str  # The address of the NFT contract
  token_id: int  # The token ID of the NFT
  license_data: list  # List of license data objects with terms and config
  max_allowed_reward_share: int  # Maximum allowed reward share percentage
  ip_metadata: dict = None  # Optional: The metadata for the IP
  deadline: int = None  # Optional: The deadline for the signature in milliseconds
  tx_options: dict = None  # Optional: Transaction options
  ```

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

### register\_group\_and\_attach\_license\_and\_add\_ips

Register a group IP with a group reward pool, attach license terms to the group IP, and add individual IPs to the group IP.

| Method                                          |
| ----------------------------------------------- |
| `register_group_and_attach_license_and_add_ips` |

Parameters:

* `group_pool`: The address of the group pool.
* `ip_ids`: List of IP IDs to add to the group.
* `license_data`: License data object with terms and config.
* `max_allowed_reward_share`: Maximum allowed reward share percentage.
* `tx_options`: \[Optional] The transaction options dictionary.

<CodeGroup>
  ```python Python theme={null}
  result = story_client.Group.register_group_and_attach_license_and_add_ips(
      group_pool="0xf96f2c30b41Cb6e0290de43C8528ae83d4f33F89",  # EvenSplitGroupPool
      ip_ids=["0x1234567890123456789012345678901234567890", "0x0987654321098765432109876543210987654321"],
      license_data={
          "license_template": "0x7e9b9B31BF5F3399D36E1E0a9E589c30Cb6925D1",  # Programmable IP License
          "license_terms_id": "5"
      },
      max_allowed_reward_share=5,  # 5%
  )
  print(f"Group registered with ID: {result['group_id']} at transaction hash {result['tx_hash']}")
  ```

  ```python Request Parameters theme={null}
  group_pool: str  # The address of the group pool
  ip_ids: list  # List of IP IDs to add to the group
  license_data: dict  # License data object with terms and config
  max_allowed_reward_share: int  # Maximum allowed reward share percentage
  tx_options: dict = None  # Optional: Transaction options
  ```

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

### collect\_and\_distribute\_group\_royalties

Collect royalties for the entire group and distribute the rewards to each member IP's royalty vault.

| Method                                   |
| ---------------------------------------- |
| `collect_and_distribute_group_royalties` |

Parameters:

* `group_ip_id`: The ID of the group IP.
* `currency_tokens`: List of currency token addresses.
* `member_ip_ids`: List of member IP IDs.
* `tx_options`: \[Optional] The transaction options dictionary.

<CodeGroup>
  ```python Python theme={null}
  result = story_client.Group.collect_and_distribute_group_royalties(
      group_ip_id="0x089d75C9b7E441dA3115AF93FF9A855BDdbfe384",
      currency_tokens=["0x1514000000000000000000000000000000000000"],  # $WIP
      member_ip_ids=["0x1234567890123456789012345678901234567890", "0x0987654321098765432109876543210987654321"]
  )
  print(f"Collected royalties: {result['collected_royalties']}")
  print(f"Royalties distributed: {result['royalties_distributed']}")
  ```

  ```python Request Parameters theme={null}
  group_ip_id: str  # The ID of the group IP
  currency_tokens: list  # List of currency token addresses
  member_ip_ids: list  # List of member IP IDs
  tx_options: dict = None  # Optional: Transaction options
  ```

  ```python Response theme={null}
  {
    "tx_hash": str,  # The transaction hash
    "collected_royalties": list,  # List of collected royalties with token address and amount
    "royalties_distributed": list  # List of distributed royalties with IP ID, token address, and amount
  }
  ```
</CodeGroup>
