Skip to main content

Prerequisites

Before you begin, make sure you have:

Node.js

Version 18 or higher Download from nodejs.org

Solana Wallet

Phantom or Solflare You need a wallet with some SOL for transaction fees

Verified NFT

Any Verified Collection An NFT from any verified Solana collection to transform into an agent

Step 1: Installation

Choose your preferred package manager:
npm install @maikers/mainframe-sdk @solana/web3.js

Step 2: Initialize the SDK

The SDK provides helper methods for common environments.

Browser / React (Wallet Adapter)

import { QuickStartIntegrations } from "@maikers/mainframe-sdk";
import { useWallet, useConnection } from "@solana/wallet-adapter-react";

function MyComponent() {
  const { wallet } = useWallet();
  const { connection } = useConnection();

  const initSdk = async () => {
    if (!wallet || !wallet.adapter) return;

    // Auto-configured for Mainnet
    const sdk = QuickStartIntegrations.walletAdapter(
      wallet.adapter,
      connection,
    );
    return sdk;
  };
}

Node.js / Backend

import { createMainnetSDK } from "@maikers/mainframe-sdk";

const sdk = createMainnetSDK({
  storage: {
    arweave: { gateway: "https://arweave.net" },
  },
});

// You'll need to initialize with a wallet adapter or keypair for write operations
// await sdk.initialize(walletAdapter);

Step 3: Create Your First Agent

Transform a verified NFT into an AI agent. This operation costs 0.05 SOL (Standard) but is FREE for Genesis collections.
import { PublicKey } from "@solana/web3.js";

async function createMyAgent(sdk, nftMintAddress) {
  try {
    const nftMint = new PublicKey(nftMintAddress);

    const result = await sdk.createAgent(nftMint, {
      name: "Trading Bot Alpha",
      description: "My first automated trading agent",
      framework: "elizaOS",
      capabilities: [
        {
          type: "defi",
          plugins: ["jupiter-swap", "birdeye-data"],
        },
      ],
    });

    console.log("✅ Agent created successfully!");
    console.log("Agent PDA:", result.agentPda.toString());
  } catch (error) {
    console.error("❌ Failed to create agent:", error);
  }
}

Step 4: Add Affiliate Revenue (Optional)

Monetize your integration by adding your wallet as an affiliate. You earn 15-50% commission on the creation fee.
const result = await sdk.createAgent(nftMint, agentConfig, {
  affiliate: "YOUR_WALLET_ADDRESS_HERE",
  // Optional: Split 5% of your earnings with a referrer
  referrer: "REFERRER_WALLET_ADDRESS",
});

Next Steps

Troubleshooting

Common Cause: The NFT collection is not verified on-chain. Solution: Ensure the NFT belongs to a collection where Collection.verified = true. Mainframe requires this for security.
Common Cause: Not enough SOL for the creation fee (0.05 SOL) + rent. Solution: Ensure your wallet has at least 0.06 SOL.