AXES
AXES - Agents on Chain
AXES - Agents on Chain
  • Introduction
    • Problem Statement
    • Vision and Mission
    • The Solution
    • How Axes Addresses the Identified Problems
    • Benefits for Users and AI Developers
  • Core Concepts
  • Core Components
    • AXES Protocol
    • AXES Smart Account
    • Optimal Model Retrieval Protocol
      • OMRP in the AXES Ecosystem
      • Architecture Overview
      • Components
      • Workflow
      • Smart Contracts in OMRP
    • Smart Hub - AI App Marketplace
    • App Node Clients
    • AIGC
      • Ownership and Monetization
  • User Guide
    • Creating an AXES Smart Account
    • Using the AI Marketplace
    • What is Canvas?
  • Developer Guide
    • AXES Connect
    • How to Publish on AXES
    • Technical Documentation
      • AXES Connect SDK
        • Installation
        • Initialization
        • Key Features
          • Wallet Connection
          • Token Bound Account (TBA) Management
          • DID Operations
          • Verifiable Credential Management
          • DID Document Generation
          • Smart Contract Interactions
          • Error Handling
          • Integration Example
  • Use Cases
    • AI-Powered Brand Collaboration
    • Personal AI Development
  • Roadmap
Powered by GitBook
On this page
  1. Developer Guide
  2. Technical Documentation
  3. AXES Connect SDK
  4. Key Features

Integration Example

Here's an example of how to create a Token Bound Account using WalletConnect:

import { AxesConnect } from 'axes-connect-sdk';

async function createTBA() {
  const axesConnect = new AxesConnect({ apiKey: 'YOUR_API_KEY' });
  
  // 1. Connect wallet
  const session = await axesConnect.wallet.connect();
  
  // 2. Fetch wallet address
  const walletAddress = session.accounts[0];
  
  // 3. Check for existing TBA
  const tbaExists = await axesConnect.tba.checkExistence(walletAddress);
  
  if (!tbaExists) {
    // 4. Create new TBA
    const newTBA = await axesConnect.tba.create(walletAddress);
    
    // 5. Wait for transaction confirmation
    await axesConnect.utils.waitForConfirmation(newTBA.transactionHash);
    
    // 6. Update UI and store data
    console.log('TBA created successfully:', newTBA.address);
    
    // 7. Enable TBA functionalities
    await axesConnect.tba.enableFeatures(newTBA.address);
    
    // 8. Notify user
    axesConnect.notifications.send({
      type: 'TBA_CREATED',
      address: newTBA.address
    });
  } else {
    console.log('TBA already exists for this wallet');
  }
}

createTBA().catch(console.error);
PreviousError HandlingNextUse Cases

Last updated 8 months ago