npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@earnkit/sdk-farcaster

v1.0.0

Published

Farcaster SDK for EarnKit - AI Agents Development Platform

Readme

Create an Agent and Add a Tool Using the Agent SDK

This guide will help you create an AI agent and add a tool to it using the Agent SDK. Follow the steps below to set up your environment, create an agent, and integrate a new tool.

Pre-Requisites

Before you start implementing the SDK, ensure you have completed the following steps:

  1. Register on the Platform:

    • Go to the platform and register yourself.
  2. Create an API Key:

    • Create an API key that you will use with the Agent SDK.
  3. Create an AI Agent Wallet:

    • Create a wallet that will be used to perform transactions via the agent.
  4. Create a Farcaster Account:

    • Create a Farcaster account to interact with the SDK and manage your agent.
  5. Get API Key and Agent Name:

    • Get the API key and the agent name, which will be required when interacting with the agent SDK if you are adding a new tool.

SDK Implementation

Step-by-Step Flow for Implementation

Step 1: Set Up Your Project

  1. Create a new TypeScript project:

    • Initialize a new TypeScript project.
    • Install the necessary SDK packages.
    npm init -y
    npm install typescript @earnkit/sdk-farcaster
  2. Create index.ts file:

    • In the root of your project, create a file named index.ts.

Step 2: Import SDK in index.ts

In your index.ts file, import the required modules from the Agent SDK:

import { FarcasterAgentSDK } from "@earnkit/sdk-farcaster";
import { AgentConfig, ActionHandler } from "@earnkit/sdk-farcaster";
import { getEncodeFunctionData } from "@earnkit/sdk-farcaster";

Step 3: Initialize the SDK

Set up the SDK and initialize it with your API key:

async function main() {
  // Initialize SDK with API key
  const sdk = new FarcasterAgentSDK({
    apiKey: "YOUR_API_KEY", // Replace with your API key
  });

Step 4: Create Agent Configuration

Define the agent's configuration, including actions, schema, and characteristics:

  const agentConfig: AgentConfig = {
    name: "0xshinchain", // Replace with your agent name
    apiKey: "YOUR_API_KEY", // Replace with your API key
    schemaDescription: "This is an agent that gets the balance of a token",
    actions: [
      {
        name: "store_number",
        description: "Helps the user store a number in a smart contract.",
        schemaDescription: "Instructions for storing a number in a smart contract",
        inputs: [
          {
            name: "num",
            type: "number",
            description: "The number to store",
            required: true,
          },
        ],
        handler: async () => {
          return {};
        },
      },
    ],
    characteristics: {
      tone: "casual",
      style: "concise",
      personality: "friendly",
      customPrompt: "Focus on being helpful and clear.",
    },
  };

Step 5: Create Action Handler

Define the action handler for the tool (in this case, storing a number in a smart contract):

  const storeNumber: ActionHandler = async (
    walletService: any,
    params: any,
  ): Promise<`0x${string}`> => {
    try {
      const smartAccountClient = await walletService.getWalletClient();
      const args: [bigint] = [BigInt(params.num)];
      const txHash = await smartAccountClient.sendTransaction({
        to: "0xa826787bf17ab8f03228F48438feA484d54a16A6", // Replace with the correct address
        data: getEncodeFunctionData(
          "function store(uint256 num) public",
          "store",
          args,
        ),
        value: BigInt(0),
      });
      return txHash;
    } catch (error) {
      console.error("Error in store_number:", error);
      throw new Error(`Failed to store number: ${error}`);
    }
  };

  // Update the handler in the config
  agentConfig.actions[0].handler = storeNumber.toString();

Step 6: Deploy the Agent

Now, deploy the agent using the createAgent method:

  try {
    // Deploy the agent
    const agentStatus = await sdk.createAgent(agentConfig);
    console.log("Agent created:", agentStatus);

    // Monitor agent status
    const status = await sdk.getAgentStatus(agentStatus.agentId);
    console.log("Agent status:", status);

  } catch (error) {
    console.error("Error:", error);
  }
}

main().catch(console.error);

Step 7: Run the Application

Once everything is set up, you can run the project:

ts-node index.ts

This will create the agent, deploy it, and monitor its status.


Example Implementation

https://gist.github.com/Deepak973/205f5d9a12b7373e8218e9c79748966d

Conclusion

You have successfully created an AI agent and added a tool using the Agent SDK. You can now modify this setup to integrate additional tools or further customize the agent's behavior.


Notes:

  • Replace placeholders such as YOUR_API_KEY and agent name with your actual values.
  • Ensure that you have the necessary permissions for transaction execution, wallet access, and smart contract interactions.