📜Fractional Ownership

Fractional ownership of AI agents allows multiple users to own a portion of an AI agent, enabling collaborative investment and ownership. This model is particularly useful for high-value AI agents where the cost of full ownership might be prohibitive. By fractionalizing the ownership, Capx makes it possible for more users to invest in and benefit from AI agents.


How Fractional Ownership Works

  1. Creating an AI Agent NFT:

    • Each AI agent on Capx is represented by a Non-Fungible Token (NFT) that encapsulates all the details about the agent, including its code, operational parameters, and monetization settings.

  2. Fractionalizing the NFT:

    • The NFT representing the AI agent can be fractionalized into multiple ERC-20 tokens, each representing a share of the AI agent.

    • These fractions can be bought, sold, and traded, allowing multiple users to own a portion of the AI agent.

  3. Trading and Liquidity:

    • Fractional ownership enables the creation of liquidity pools, allowing users to trade fractions of AI agents on the Capx platform.

    • This provides liquidity and price discovery for AI agent fractions, making it easier for investors to enter and exit positions.


Solidity Code for Agent NFT and Fractions

Below is an example of how to implement fractional ownership of AI agents using Solidity. This example includes the creation of an ERC-721 NFT for the AI agent and the fractionalization into ERC-20 tokens.

Agent NFT (ERC-721)

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract AgentNFT is ERC721, Ownable {
    uint256 public nextTokenId;
    address public admin;

    constructor() ERC721("AgentNFT", "AIA") {
        admin = msg.sender;
    }

    function mint(address to) external onlyOwner {
        _safeMint(to, nextTokenId);
        nextTokenId++;
    }

    function setAdmin(address newAdmin) external onlyOwner {
        admin = newAdmin;
    }

    function _baseURI() internal view virtual override returns (string memory) {
        return "https://api.capx.ai/metadata/";
    }
}

Fractional Ownership (ERC-20)

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract FractionalToken is ERC20, Ownable {
    IERC721 public agentNFT;
    uint256 public tokenId;
    bool public fractionsCreated;

    constructor(address _agentNFT, uint256 _tokenId) ERC20("AgentFraction", "AIF") {
        agentNFT = IERC721(_agentNFT);
        tokenId = _tokenId;
        fractionsCreated = false;
    }

    function createFractions(uint256 amount) external onlyOwner {
        require(agentNFT.ownerOf(tokenId) == address(this), "Contract does not own the NFT");
        require(!fractionsCreated, "Fractions already created");
        _mint(msg.sender, amount);
        fractionsCreated = true;
    }

    function redeem(uint256 amount) external {
        require(fractionsCreated, "Fractions not created yet");
        _burn(msg.sender, amount);
        if (totalSupply() == 0) {
            agentNFT.transferFrom(address(this), msg.sender, tokenId);
            fractionsCreated = false;
        }
    }
}

How to Use the Contracts

  1. Deploy the AgentNFT Contract:

    • Deploy the AgentNFT contract to create NFTs representing AI agents.

    • Use the mint function to create a new NFT for each AI agent.

  2. Deploy the FractionalToken Contract:

    • Deploy the FractionalToken contract with the address of the AgentNFT contract and the tokenId of the AI agent NFT.

    • Use the createFractions function to mint ERC-20 tokens representing fractions of the AI agent NFT.

  3. Trading Fractions:

    • Once the fractions are created, they can be traded on the Capx platform or any compatible ERC-20 marketplace.

    • Users can buy and sell fractions, providing liquidity and enabling collaborative ownership.

  4. Redeeming Fractions:

    • Users can redeem their fractions to take full ownership of the AI agent NFT if they hold all the fractions.

    • The redeem function burns the fractions and transfers the AI agent NFT to the user.


Fractional ownership on Capx democratizes access to high-value AI agents by allowing multiple users to invest in and benefit from these assets. By implementing the provided Solidity contracts, developers can easily create and manage fractional ownership of AI agents, enabling innovative monetization strategies and enhancing liquidity within the Capx ecosystem.

Last updated