How to Build a Copy-Trading AI Agent

Introduction

Discover how to create a powerful copy-trading AI agent on Loomlay that automates buying tokens based on social media signals. This step-by-step guide will walk you through building an agent that follows trading signals from the aixbt_agent Twitter account, checks token availability, and executes trades on Base.

Watch the Video Tutorial

Step-by-Step Instructions

Step 1: Fetch Latest Tweets

Start by configuring your agent to fetch the latest tweets from aixbt_agent and identify mentioned tickers. Use the Twitter plugin to:

  • Retrieve tweets from the specified account.

  • Extract tickers mentioned in the tweets.

  • Log these tickers for later use.

Step 2: Analyze Tickers with Dexscreener

Use the Dexscreener plugin to search for the tickers and determine which blockchain they’re on:

  • Query each ticker.

  • Identify the blockchain associated with each token.

  • Log the tokens and their respective chains.

Step 3: Filter for Base Chain Tokens

Focus on tokens available on Base:

  • Filter the logged tickers to retain only those on Base.

  • Retrieve the contract addresses for these tokens.

  • Log the contract addresses for future operations.

Step 4: Check Wallet Balances

Configure your agent to:

  • Check your wallet for balances of the Base chain tokens.

  • Identify tokens that are not currently held in your wallet.

Step 5: Check ETH Balance

Ensure you have enough ETH for the transaction:

  • Verify your wallet’s ETH balance.

  • If the balance exceeds 0.001 ETH, proceed to the next step.

Step 6: Swap ETH for the Found Token

Execute the trade:

  • Swap 0.001 ETH for the token that you don’t currently hold.

  • Log the transaction hash as confirmation.

Step 7: Finish and Return Transaction Details

Complete the workflow by:

  • Returning the transaction hash.

  • Logging the process to ensure everything executed as intended.

Last updated