Skip to content

UXlySoftware/1shot-agentkit

Repository files navigation

Watch the tutorial

1Shot Prompts Action Provider for AgentKit

This repository implements an Action Provider for the AgentKit onchain agents framework. Specifically, it injects any smart contract imported into the developer's 1Shot API business account as a callable tool with overlayed prompt instructs that can be writted/edited by the developer or other 1Shot Prompts contributors.

Contracts as Tools

1Shot Prompts allows contributed to write high-quality prompt overlays for verified smart contracts in the EVM ecoystem and publish this templates for other developers to import into their 1Shot API context. When an agent hits the list-methods endpoint, the available smart contract methods and their associated annotations are returned which can then be leveraged by the LLM for better reasoning about tool calling.

Action Provider

1Shot Prompts can be imported as an AgentKit action provider:

    // Initialize AgentKit: https://docs.cdp.coinbase.com/agentkit/docs/agent-actions
    const actionProviders: ActionProvider[] = [
      walletActionProvider(),
      new OneShotActionProvider(
        process.env.ONE_SHOT_API_KEY ?? "INVALID_API_KEY",
        process.env.ONE_SHOT_API_SECRET ?? "INVALID_API_SECRET",
        process.env.ONE_SHOT_BUSINESS_ID ?? "INVALID_BUSINESS_ID",
      ),
    ];

    const canUseCdpApi =
      process.env.CDP_API_KEY_ID && process.env.CDP_API_KEY_SECRET;
    if (canUseCdpApi) {
      actionProviders.push(
        cdpApiActionProvider({
          apiKeyId: process.env.CDP_API_KEY_ID,
          apiKeySecret: process.env.CDP_API_KEY_SECRET,
        }),
      );
    }
    
    const agentkit = await AgentKit.from({
      walletProvider,
      actionProviders,
    });

Using only this action provider, an AgentKit-powered agent can read and write to any smart contract on any EVM network. The Action Provider supports 3 different execution modes:

  1. Submission through the agent's wallet
  2. Submission through 1Shot API's server-side wallets
  3. Delegated execution through the use of 7702-style smart wallets.

Development Instructions

This is a Next.js project bootstrapped with create-onchain-agent.

It integrates AgentKit to provide AI-driven interactions with on-chain capabilities.

Getting Started

First, install dependencies:

npm install

Then, configure your environment variables:

mv .env.local .env

Run the development server:

npm run dev

Open http://localhost:3000 in your browser to see the project.

Configuring Your Agent

You can modify your configuration of the agent. By default, your agentkit configuration occurs in the /api/agent/prepare-agentkit.ts file, and agent instantiation occurs in the /api/agent/create-agent.ts file.

1. Select Your LLM

Modify the OpenAI model instantiation to use the model of your choice.

2. Select Your Wallet Provider

AgentKit requires a Wallet Provider to interact with blockchain networks.

3. Select Your Action Providers

Action Providers define what your agent can do. You can use built-in providers or create your own.


Next Steps

  • Explore the AgentKit README: AgentKit Documentation
  • Learn more about available Wallet Providers & Action Providers.
  • Experiment with custom Action Providers for your specific use case.

Learn More


Contributing

Interested in contributing to AgentKit? Follow the contribution guide:

About

1Shot Prompts integration with Coinbase's AgentKit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •