# Nit Bubble Plugin

## Plugin Config

Before using the plugin, please fill the following three on the plugin config page.

<figure><img src="https://2105393165-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsJ8b1FUIurgQducTQQ2z%2Fuploads%2FkONmdPVxwSOxOcpp6Skd%2Fnit-plugin-config.png?alt=media&#x26;token=a5c04d5f-d37b-4bee-967a-b8ddf2b7d9c4" alt=""><figcaption></figcaption></figure>

* `contractAbiUrl` : [https://dd7tel2830j4w.cloudfront.net/f1647618631535x514063401428340740/IntegrityRegister.json](https://dd7tel2830j4w.cloudfront.net/f1647618631535x514063401428340740/IntegrityRegister.json)
* `network`: jade
* `nitconfig`: Please replace the placeholder for `private-key` with your own wallet's private key and add the provided config to the Bubble plugin. It is important to note that Infura configuration is only necessary if you plan to commit data. Read-only functions, such as `getCommitsFromCid`, do not require Infura keys.

```json
{
    "defaultNetwork": "jade",
    "provider": "bafkreigrt5tepycewppysdwcjccdkdvvc2ztelqv64idgautq52g3vfh4i",
    "infura": {
        "projectId": YOUR_INFURA_PROJECT_ID,
        "projectSecret": YOUR_INFURA_PROJECT_SECRET
    },
    "network": {
        "jade": {
          "url": "https://mainnetrpc.num.network",
         "chainId": 10507,
         "accounts": [
           YOUR_PRIVATE_KEY
          ],
          "contract": "0x7EC2F14ABE8b0Ea2F657bBb62b6fEfDe161c9001",
          "explorerBaseUrl": "https://mainnet.num.network/tx"
        },
        "snow": {
          "url": "https://testnetrpc.num.network",
          "chainId": 10508,
          "accounts": [
            YOUR_PRIVATE_KEY
          ],
          "contract": "0x02eFA51b583d03342687b585417e5A62cd8273a4",
          "explorerBaseUrl": "https://testnet.num.network/tx"
        },
    }
}
```



## getCommitsFromCid

The Bubble nit plugin is a powerful tool for no-code/low-code developers looking to easily commit data to the Numbers blockchain. This plugin offers two methods for accessing commit logs:

1. Using the `getCommitsFromCid` function, developers can retrieve all commits for a specific asset by providing the asset's CID as input. This method is convenient as it returns all commits at once, allowing for easy parsing and manipulation of the data.
2. Alternatively, developers can use the `getBlocks` function to retrieve the blocks of a specific asset and then use the `getCommit` function to retrieve the commits within each block. While this method may be more efficient for assets with a large number of commits (over 20), it does require additional steps and manipulation of the data.

It is important to note that when working with a large number of commits, using the `getCommitsFromCid` function may result in slow response times and potential timeouts. In such cases,  `getBlocks` and `getCommit` method may be more suitable.

{% code overflow="wrap" %}
```javascript
Description:
The getCommitsFromCid function is a powerful feature that allows users to retrieve detailed information about the commits related to a specific asset. The function takes an assetCid as input and returns a list of commits that have been made to that asset. 

Function: 
getCommitsFromCid(assetCid)

Input:
assetCid (text): The Nid of the asset for which to retrieve commit information.

Output:
authors (list of text): A list of the addresses of the user who create the commit.
timestamps (list of number): A list of the timestamps of when the commit was made.
commits (list of text): A list of the full commit messages.
transactions (list of text): A list of the transaction that was used to make the commit.
assetTreeCids (list of text): A list of the assetTree Nids found in the commit.
```
{% endcode %}

## getBlocks

The `getBlocks` function allows users to acquire blocks of the commits. This function takes an assetCid as input, and returns a list of all the blocks that contain commits related to that specific asset. This function should always be run before using getCommits function.

## getCommits

The `getCommits` function allows users to retrieve commits from the Numbers blockchain. This function is particularly useful for tracking the history of changes made to a specific asset, such as a digital document, image, or video. The getCommits function takes a block number as input, and returns the specific commit that was made within that block. This information includes details such as the authors of the commit, the timestamp of the commit, and the commit message.

## getAssetTree

The `getAssetTree` function accept the [Cid/Nid](../../introduction/numbers-protocol/defining-web3-assets/numbers-id-nid) of your [AssetTree](../../introduction/numbers-protocol/defining-web3-assets/assettree) and return the parsed results retrieved from IPFS.

<pre class="language-javascript"><code class="lang-javascript"><strong>Function: 
</strong>getAssetTree(assetTreeCid)

Input:
assetTreeCid (text): The Cid/Nid of the AssetTree.

Output:
assetCid: (string) The Nid of the asset file
assetCreator: (string) Name of the asser creator
encodingFormat: (string) The asset's type expressed using a MIME format
assetTimestampCreated: (string) Creation time of the asset file
assetSha256: (string) SHA-256 hash of the asset file
abstract: (string) A summary or abstract of the asset
headline: (string, optional) Headline or the title of the content file
creatorWallet: (string) Wallet address of the asset creator
licenseName: (string) License of the asset file
licenseDocument: (string) URL of the license file
usedBy: (string) URL of the website that uses the asset
nftRecord: (string) IPFS Cid where you can find all the NFT records. jav
custom: (string) Stringified JSON object containing custom metadata
</code></pre>

## commit

The `commit` function is a core feature of the nit plugin, allowing users to commit logs for digital media files to the Numbers blockchain.

## ipfsCat

The `ipfsCat` function is a util tool that allows you to retrieve metadata associated with a given IPFS Content Identifier (Cid) from the Numbers IPFS gateway. The function takes a single input, the Cid, which should be passed as a string. The function will return the metadata as a string, which can be parsed as JSON or other formats as desired.

```javascript
Description:
ipfsCat helps you cat metadata with IPFS Nid/Cid from Numbers IPFS gateway

Function: 
ipfsCat(cid)

Input:
cid (text): The IPFS Cid of the metadata for which to retrieve

Output:
data (string): The data fetched from the IPFS Nid/Cid
```
