> For the complete documentation index, see [llms.txt](https://cryptoinnovators.gitbook.io/ava-the-defai-agent/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cryptoinnovators.gitbook.io/ava-the-defai-agent/integrations/story-protocol.md).

# Story Protocol

## Overview

Ava integrates with Story Protocol to provide decentralized IP management, licensing, and royalty distribution for AI-generated content. This integration enables proper attribution, terms enforcement, and commercial usage rights for content generated by Ava's portfolio management agents.

## Components

### ATCP-IP Provider

The ATCP-IP (Automated Token-based Content Provenance for Intellectual Property) provider serves as the bridge between Ava's AI agents and Story Protocol's on-chain IP management system. It enables:

* Creation and management of intellectual property licenses for AI-generated insights, strategies, and content
* Registration of agent outputs with proper attribution
* Enforcement of royalty payments for commercial use of IP
* Tracking of IP across the Ava ecosystem

```typescript
interface IPLicenseTerms {
  name: string;
  description: string;
  scope: string;
  transferability: boolean;
  onchain_enforcement: boolean;
  royalty_rate: number;
}

interface IPMetadata {
  license_id: string;
  issuer_id: string;
  holder_id: string;
  issue_date: number;
  version: string;
  link_to_terms: string;
  previous_license_id: string;
}
```

### Recall Storage

The Recall Storage provider enables Ava's agents to persistently store and retrieve data using the decentralized Recall protocol. This includes:

* On-chain storage of agent outputs, analysis, and decision logic
* Immutable record-keeping of portfolio actions and strategies
* Decentralized retrieval and verification of historical data
* Chain-of-thought storage for agent decision paths

Key features include:

* Encrypted storage buckets for different types of agent data
* Searchable indexed storage for fast retrieval
* Metadata tagging for organization and filtering

## How It Works

### IP Licensing Flow

1. **Content Generation**: Ava's agents generate portfolio analysis, strategies, or other valuable IP
2. **IP Registration**: Content is registered with Story Protocol via the ATCP-IP provider:

   ```typescript
   const licenseId = await atcpipProvider.mintLicense(terms, metadata);
   ```
3. **License Terms**: Clear terms are established for content usage, including:
   * Commercial vs. non-commercial use
   * Royalty rates (typically 5% default)
   * Attribution requirements
   * Transferability permissions
4. **Verification and Attribution**: Consumers of the content can verify authenticity and view attribution:

   ```typescript
   const isValid = await atcpipProvider.verifyLicense(licenseId);
   const terms = await atcpipProvider.getLicenseTerms(licenseId);
   ```

### Persistent Data Storage Flow

1. **Agent Analysis**: Ava's agents perform portfolio analysis or generate strategies
2. **Data Persistence**: Critical data is stored using the Recall Storage provider:

   ```typescript
   await recallStorage.store(key, data, metadata);
   ```
3. **Chain of Thought**: Decision-making processes are stored for transparency and auditing:

   ```typescript
   await recallStorage.storeCoT(key, thoughts, metadata);
   ```
4. **Retrieval and Search**: Data can be accessed and searched when needed:

   ```typescript
   const result = await recallStorage.retrieve(key);
   const searchResults = await recallStorage.search(query, options);
   ```

## Benefits

* **IP Protection**: Ensures proper attribution and royalty distribution for AI-generated financial insights
* **Decentralized Record-Keeping**: Creates tamper-proof records of strategies and decisions
* **Compliance**: Enables clear licensing terms for commercial use of strategies
* **Transparency**: Provides audit trails for agent decision-making
* **Interoperability**: Allows content to be securely shared across the DeFi ecosystem with proper rights management

## Future Enhancements

* Enhanced royalty distribution models for collaborative AI-generated strategies
* Integration with additional blockchains beyond the current deployments
* Advanced IP rights management for specialized portfolio strategies
* Cross-agent licensing for collaborative strategy development
* NFT-based strategy marketplaces with built-in licensing
