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

# Class: MockLicensingProtocol

Client for the Mock Licensing Protocol contract.
Used for testing and development purposes on Cultura testnets.

This client interacts with a mock contract that simulates the actions a real
licensing protocol might take. It allows developers to test the end-to-end flow
of licensing a Level 2 asset and creating/verifying a Licensed Creative Asset
without needing a fully functional external protocol.

## Remarks

This client is for testing and demonstration purposes only.
Should not be used in production environments.

### new MockLicensingProtocolClient()

> **new MockLicensingProtocolClient**(`publicClient`, `walletClient`, `contractAddress`, `culturaDigitalAssetAddress`, `attestationServiceAddress`, `chainType`): [`MockLicensingProtocolClient`](./mock-licensing-protocol)

#### Parameters

##### publicClient

##### walletClient

##### contractAddress

`` `0x${string}` ``

##### culturaDigitalAssetAddress

`` `0x${string}` ``

##### attestationServiceAddress

`` `0x${string}` ``

##### chainType

[`CulturaChainType`](../types/cultura-chain-type)

#### Returns

[`MockLicensingProtocolClient`](./mock-licensing-protocol)

## Methods

### licenseDigitalAsset()

> **licenseDigitalAsset**(`collectionAddress`, `tokenId`): `Promise`\<`` `0x${string}` ``>

Simulate registering a token ID as licensed within the mock protocol.

#### Parameters

##### collectionAddress

`` `0x${string}` ``

The address of the collection that the token is licensed from

##### tokenId

`bigint`

The ID of the token to license

#### Returns

`Promise`\<`` `0x${string}` ``>

Transaction hash

#### Remarks

This method simulates the action of a licensing protocol granting a license
for a specific parent token. It records this "license granted" status within
the mock contract's state for the given `collectionAddress` and `tokenId`.

This should typically be called *before* minting the Licensed Creative Asset.
It represents securing the rights needed for the next step.

In a real-world scenario, this step would involve interacting with an actual
licensing protocol, potentially involving off-chain agreements, payments,
and specific license term negotiations.

#### Example

```typescript theme={null}
// License an existing token
const collectionAddress = "0xcollection123...";
const tokenId = BigInt(42);

const txHash = await mockLicensingClient.licenseDigitalAsset(
  collectionAddress,
  tokenId
);

console.log(`Token licensed with transaction: ${txHash}`);
```

### verifyLicensedAsset()

> **verifyLicensedAsset**(`attestationUID`, `bondedAmount`): `Promise`\<`` `0x${string}` ``>

Simulate verifying the attestation of a Licensed Creative Asset.

#### Parameters

##### attestationUID

`` `0x${string}` ``

The attestation UID to verify

##### bondedAmount

`bigint`

The amount to bond for verification

#### Returns

`Promise`\<`` `0x${string}` ``>

Transaction hash

#### Remarks

This method simulates a licensing protocol performing a verification check on an
*attestation* associated with a Licensed Creative Asset. It takes the
`attestationUID` (obtained after calling `sdk.attestationService.attest` on the
*new* Licensed Creative Asset) and a `bondAmount`.

In the context of the mock protocol, this function likely interacts with the main
`CAS.verifyAttestation` function, effectively acting as a verifier endorsing the
new asset's attestation. It represents the final step where the licensing body
confirms the validity of the newly created and attested licensed asset.

The `bondedAmount` is used for the underlying CAS verification.

#### Example

```typescript theme={null}
// Verify a licensed asset
const attestationUID = "0xattestation123...";
const bondAmount = BigInt("500000000000000000"); // 0.5 tokens

const txHash = await mockLicensingClient.verifyLicensedAsset(
  attestationUID,
  bondAmount
);

console.log(`Asset verification initiated with transaction: ${txHash}`);
```

### getLicensedTokens()

> **getLicensedTokens**(`address`): `Promise`\<`object`\[]>

Get licensed tokens for a specific address.

#### Parameters

##### address

`` `0x${string}` ``

The address to check licensed tokens for

#### Returns

`Promise`\<`object`\[]>

Array of licensed tokens with their collection addresses and token IDs

### isTokenLicensedByAddress()

> **isTokenLicensedByAddress**(`address`, `collectionAddress`, `tokenId`): `Promise`\<`boolean`>

Check if a specific address has licensed a specific token.

#### Parameters

##### address

`` `0x${string}` ``

The address to check

##### collectionAddress

`` `0x${string}` ``

The collection address to check

##### tokenId

`bigint`

The token ID to check

#### Returns

`Promise`\<`boolean`>

Boolean indicating whether the address has licensed the token

### isLicensedToken()

> **isLicensedToken**(`collectionAddress`, `tokenId`): `Promise`\<`boolean`>

Check if a token is properly licensed by the current wallet

#### Parameters

##### collectionAddress

`` `0x${string}` ``

The collection address to check

##### tokenId

`bigint`

The token ID to check

#### Returns

`Promise`\<`boolean`>

Boolean indicating whether the token is properly licensed by the current wallet

### isRightsBoundAccountVerified()

> **isRightsBoundAccountVerified**(`rightsBoundAccount`): `Promise`\<`boolean`>

Check if a Rights Bound Account corresponds to a verified asset

#### Parameters

##### rightsBoundAccount

`` `0x${string}` ``

The Rights Bound Account address to check

#### Returns

`Promise`\<`boolean`>

Boolean indicating whether the RBA corresponds to a verified asset

#### Remarks

This method uses the RightsBoundAccountClient to get the associated
digital asset information, then checks the on-chain verification level.
This approach is more reliable than depending on subgraph indexing.

### createLicensedAsset()

> **createLicensedAsset**(`licensedAssetDetails`, `licenseeSignature`, `schemaUID`, `bondAmount`, `classId`, `parentRights`, `externalNFT`?, `termsURI`?): `Promise`\<\{ `licensedAssetId`: `bigint`; `attestationInfo`: \{ `attestationUid`: `` `0x${string}` ``; `rightsBoundAccount`: `` `0x${string}` ``; }; `transactionState`: `"complete"` | `"failed"`; }>

(Convenience Function) Create and attest a Licensed Creative Asset in one step.
This method allows for creation of licenses for both Cultura and external NFTs.

#### Parameters

##### licensedAssetDetails

License details including name, description, and terms

###### name

`string`

###### description

`string`

###### imageUrl?

`string`

##### licenseeSignature

[`SignatureParams`](../types/signature-params)

The licensee's signature validating acceptance of terms

##### schemaUID

`` `0x${string}` ``

Schema UID to use for the attestation

##### bondAmount

`bigint` = `...`

Amount to bond for the attestation (defaults to 1.1 tokens in wei)

##### classId

`bigint`

##### parentRights

readonly `Readonly`\<\{ `rightsBoundAccount`: `` `0x${string}` ``; `royaltySplit`: `bigint`; }>\[]

Array of parent rights information for derivative works

##### externalNFT?

Optional information about an external NFT being licensed

###### collection

`` `0x${string}` ``

###### tokenId

`bigint`

###### owner

`` `0x${string}` ``

##### termsURI?

`string`

Optional URI pointing to the terms document (defaults to the imageUrl or a dummy value)

#### Returns

`Promise`\<\{ `licensedAssetId`: `bigint`; `attestationInfo`: \{ `attestationUid`: `` `0x${string}` ``; `rightsBoundAccount`: `` `0x${string}` ``; }; `transactionState`: `"complete"` | `"failed"`; }>

Object containing the newly created asset details, attestation info, and compliance status

#### Remarks

**Note:** This is a **convenience function** specific to the mock protocol that
combines the minting and attestation steps for a Licensed Creative Asset.
**Crucially, it requires that `licenseDigitalAsset` has already been called**
for each parent asset involved to register the license grant within the mock contract.
This function *checks* for that pre-existing license state; it does *not* perform
the initial licensing simulation itself.

For a clearer understanding of the individual protocol interactions, refer to the
step-by-step flow:

1. `licenseDigitalAsset` (for each parent)
2. `sdk.culturaDigitalAsset.mintDigitalAsset`
3. `sdk.attestationService.attest`

This function performs the following actions:

1. **Checks** if a license has been registered for the parent asset(s) via prior
   calls to `licenseDigitalAsset` for the current wallet address.
2. Mints a new **Licensed Creative Asset** NFT via the `CulturaDigitalAsset` contract,
   linking it to the parents.
3. Immediately creates an **attestation** for the *newly minted* asset via the `CAS`
   contract, using the provided `licenseeSignature`, `schemaUID`, `bondAmount`, and `assetClass`.
4. Returns the `licensedAssetId` (the tokenId of the new asset) and `attestationInfo`
   (including the `attestationUid`).

It includes transaction state tracking (`transactionState`) to indicate success or failure.
Use the `externalNFT` parameter if the license pertains to an asset outside the
Cultura `CulturaDigitalAsset` contract.

#### Example

```typescript theme={null}
// Create a license for a derivative work
const result = await mockLicensingClient.createLicensedAsset(
  {
    name: "Derivative Artwork License",
    description: "License for derivative work based on CryptoKitty #123",
    imageUrl: "https://example.com/license-image.jpg"
  },
  {
    // Licensee signature details
    signer: "0xabc...",
    signature: "0x123...",
    deadline: BigInt(Date.now() + 3600000) // 1 hour from now
  },
  "0xschema123...", // Schema UID
  BigInt("1100000000000000000"), // 1.1 tokens bond amount
  BigInt(2), // Asset class 2
  [
    {
      rightsBoundAccount: "0xRightsBoundAccount...",
      royaltySplit: BigInt(10) // 10% royalty split
    }
  ]
);

console.log(`New licensed asset created with ID: ${result.licensedAssetId}`);
console.log(`Attestation UID: ${result.attestationInfo.attestationUid}`);
```

### getVerifiedLicensedAssets()

> **getVerifiedLicensedAssets**(`limit`, `offset`): `Promise`\<\{ `assets`: [`DigitalAsset`](../types/digital-asset)\[]; `total`: `number`; }>

Get assets with verified rights.

#### Parameters

##### limit

`number` = `20`

Optional limit for the number of results to return (defaults to 20)

##### offset

`number` = `0`

Optional offset for pagination (defaults to 0)

#### Returns

`Promise`\<\{ `assets`: [`DigitalAsset`](../types/digital-asset)\[]; `total`: `number`; }>

Object containing an array of verified assets and the total count.

#### Remarks

This method uses the query system to retrieve digital assets that have been
verified (e.g., reached a certain level or status within the protocol).
The method returns details about each asset including its tokenId, name,
description, collection address, owner, attestation UID, and assetClass.

Verified assets are those that have successfully passed the verification process,
meaning they comply with all licensing terms of their parent assets (if applicable).
These assets can potentially be used as parent assets for further derivative works,
depending on the protocol rules.

#### Example

```typescript theme={null}
// Get verified licensed assets with pagination
const result = await mockLicensingClient.getVerifiedLicensedAssets(10, 0);

console.log(`Found ${result.total} verified assets`);

// Display the assets
result.assets.forEach(asset => {
  console.log(`Asset ID: ${asset.tokenId}`);
  console.log(`Name: ${asset.name}`);
  console.log(`Owner: ${asset.owner}`);
});
```
