This guide will walk through building a Twitter bot on top of the Clanker protocol similar to Bankr, Dealr, Beamr, and others. This bot will use an LLM to interpret user requests, Privy managed wallets to manage EVM accounts, and the Clanker protocol to deploy tokens on Base.

Resources

Set up your Twitter bot

To interact with users, you’ll need a Twitter developer account and a bot. Learn more here.

Set up Privy server wallets

If your app does not have access to managed wallets, request managed wallets access on your dashboard here

Privy managed wallets let you create and control EVM wallets programmatically. Learn more about getting started with managed wallets.

Using wallets

In our example application, we will build two basic interactions with Privy wallets:

  • Create a wallet
  • Get a user’s wallet

Using these core building blocks, we can allow our bot to seamlessly and securely create and manage wallets for users.

1

Create a wallet for a user

This function creates a new wallet for a user and saves the wallet ID to the database.

/**
 * Creates a new wallet for a user
 * @param userId - The Twitter user ID
 * @returns The wallet object with id, address, and other properties
 */
async function createUserWallet(userId) {
  // Create a new wallet for the user
  const wallet = await privy.walletApi.createWallet({chainType: 'ethereum'});

  // EXAMPLE: Save the wallet ID to the database to save the mapping between the user and their wallet
  await db.wallets.set(userId, wallet.id);

  return wallet;
}
2

Get a user wallet

This function checks if a user has a wallet and returns it if it exists.

/**
 * Gets a user's wallet if it exists
 * @param userId - The Twitter user ID
 * @returns The wallet object or null if no wallet exists
 */
async function getUserWallet(userId) {
  // EXAMPLE: Check if user already has a wallet
  const walletId = await db.wallets.get(userId);

  // If wallet exists, retrieve and return the wallet
  if (walletId) {
    const wallet = await privy.walletApi.getWallet(walletId);
    return wallet;
  }

  return null;
}
3

Get or create a wallet

A higher level function that uses the getUserWallet and createUserWallet functions to get or create a wallet for a user.

/**
 * Gets a user's wallet or creates one if they don't have one
 * @param userId - The Twitter user ID
 * @returns The wallet object with id, address, and other properties
 */
async function getOrCreateUserWallet(userId) {
  // Try to get existing wallet
  const existingWallet = await getUserWallet(userId);

  // Return existing wallet if found
  if (existingWallet) {
    return existingWallet;
  }

  // Create a new wallet if none exists
  return createUserWallet(userId);
}

// Example usage:
const wallet = await getOrCreateUserWallet(parsed.authorId);

Integrate LLM for intent detection

Use an LLM to interpret user messages and decide what action to take. Treat the LLM as a black box that receives a prompt and returns a structured intent.


Getting set up with Clanker API

To deploy tokens via the Clanker API, you first need to obtain an API key.

1

Request API access

  1. Visit the Clanker API documentation.
  2. Follow the instructions or contact the Clanker team via their documentation or contact page to request API access.
  3. Once approved, you’ll receive an x-api-key to use in your API requests.
2

Next: Deploy a token

Once you have your API key, you can use it to deploy tokens via the Clanker API. See the next section for a full deployment code example.


Example Interactions

Deploy a token

Let users deploy tokens on Base by simply messaging the bot. The LLM interprets the intent, and the bot handles wallet lookup/creation and token deployment.

Send tokens to another Twitter user with LLM

Let users send tokens (e.g., ETH on Base) to other Twitter users by simply messaging the bot. The LLM interprets the intent, and the bot handles wallet lookup/creation and transaction sending.