TopPointAI
  • Getting Started
    • What is TopPointAI?
      • TopPointAI
    • Integrating TopPointAI
  • User Guide
    • Placing a Trade
    • Tutorial
  • Protocol Concepts
    • Optimistic Settlement
    • Intents
    • Orderbook and Limit Orders
    • Cross-Chain Swaps
    • Challenge System
Powered by GitBook
On this page
  1. Getting Started

Integrating TopPointAI

PreviousTopPointAINextPlacing a Trade

Last updated 4 months ago

More integration examples are coming! Feel free to ping us on Telegram and we will work with you directly to fast track your integration.

Integrating TopPointAI into Client Apps

Fundamentally, there are three steps:

  1. Load the token contract addresses that the user wants to transact between & the swap TopPointAI contract on the sell-side network (and make sure that token spend is approved). You can get all of our supported tokens and networks here

  2. Build and issue a transaction that execute the placeTrade function on the TopPointAI contract, which places an order onto the order book

  3. Build and issue an API call to a backend server that fills the order (check out ours in our API doc )

Copy

/** Step 1 **/
// Check and approve the sell-side token spend on Arbitrum
await checkAndApproveAllowance(wallet);

// Load the TopPointAI contract on Arbitrum
const swapContract = getSwapContract(wallet);


/** Step 2 **/
// Build smart contract transaction function arguments
const transactionFunctionArgs = getTransactionFunctionArgs();

// Execute the token exchange by issuing smart contract transaction
const tx = await swapContract["placeTrade"](...transactionFunctionArgs);
const receipt = await tx.wait();


/** Step 3 **/
// Fetch the event log for the OrderPlaced events
const event = await getEventFromTxReceipt(receipt, swapContract);

// Make the API call
await sendEventDataToBackend(event);
here