Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/opensea Integrate Opensea Actions to Agentkit #325

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Elkhan-Isayev
Copy link

@Elkhan-Isayev Elkhan-Isayev commented Feb 9, 2025

OpenSea Action Provider for AgentKit

🚀 Overview
We are enhancing Coinbase's chat system with seamless OpenSea integration, enabling users to effortlessly browse their NFTs, select assets, and list them—all within the chat interface. This integration makes NFT trading more intuitive, accessible, and streamlined.

File Structure

agentkit/src/action-providers/opensea/
├── openSeaActionProvider.ts        # Main provider implementation
├── openSeaActionProvider.test.ts   # Test suite
├── schemas.ts                     # Schema for listing an NFT on OpenSea
└── index.ts                        # Public exports

Core Features

  1. List an NFT Action
    @CreateAction({ name: "list_nft" })
    This tool allows users to list an NFT on OpenSea. It takes the token ID, contract address, and listing price as input.

  2. Fetch NFTs of a Specific Wallet Address
    @CreateAction({ name: "get_nfts_by_account" })
    This tool fetches all NFTs associated with a given wallet address.

Technical Details

  • viemwalletprovider: Handles wallet interaction
  • openseasdk: Provides marketplace interaction
  • sepolia: Facilitates interaction over the testnet

This integration ensures that AI agents can interact with OpenSea via a secure and type-safe interface, simplifying the process for users and enabling efficient NFT trading within the chat system.

@cb-heimdall
Copy link

cb-heimdall commented Feb 9, 2025

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 -1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

@Elkhan-Isayev Elkhan-Isayev changed the title Feat/opensea Feat/opensea Integrate Opensea Actions to Agentkit Feb 9, 2025
@Elkhan-Isayev
Copy link
Author

OpenSea Action Provider for AgentKit

🚀 Overview
We are enhancing Coinbase's chat system with seamless OpenSea integration, enabling users to effortlessly browse their NFTs, select assets, and list them—all within the chat interface. This integration makes NFT trading more intuitive, accessible, and streamlined.

File Structure

agentkit/src/action-providers/opensea/
├── openSeaActionProvider.ts        # Main provider implementation
├── openSeaActionProvider.test.ts   # Test suite
├── schemas.ts                     # Schema for listing an NFT on OpenSea
└── index.ts                        # Public exports

Core Features

  1. List an NFT Action
    @CreateAction({ name: "list_nft" })
    This tool allows users to list an NFT on OpenSea. It takes the token ID, contract address, and listing price as input.

  2. Fetch NFTs of a Specific Wallet Address
    @CreateAction({ name: "get_nfts_by_account" })
    This tool fetches all NFTs associated with a given wallet address.

Technical Details

  • viemwalletprovider: Handles wallet interaction
  • openseasdk: Provides marketplace interaction
  • sepolia: Facilitates interaction over the testnet

This integration ensures that AI agents can interact with OpenSea via a secure and type-safe interface, simplifying the process for users and enabling efficient NFT trading within the chat system.

@Elkhan-Isayev
Copy link
Author

Issue ticked id: #300

@0xRAG 0xRAG added action provider New action provider needs review PR / issue needs review apple labels Feb 10, 2025
Copy link
Contributor

@0xRAG 0xRAG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @Elkhan-Isayev, this is an exciting addition! Please review and address my feedback. Also, it would be great if you could add screenshots of the action working as expected.

@@ -53,5 +53,8 @@
"turbo": "^2.3.3",
"typedoc": "^0.27.2",
"typescript": "^5.4.5"
},
"dependencies": {
"opensea-js": "^7.1.15"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to typescript/agentkit/package.json

import { z } from "zod";
import { ActionProvider } from "../actionProvider";
import { CreateAction } from "../actionDecorator";
import { OpenSeaSDK, Chain } from "opensea-js"; // Assuming an OpenSea SDK is available
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Please remove this comment

*/
export class OpenSeaActionProvider extends ActionProvider {
private readonly client: OpenSeaSDK;
private readonly walletProvider: ViemWalletProvider;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest extending ViemWalletProvider which will configure a PublicClient / WalletClient. Then you'll also be able to remove the walletPrivateKey config parameter

*/
export interface OpenSeaActionProviderConfig {
apiKey?: string;
walletPrivateKey: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment below about removing this

Comment on lines +39 to +43
/*
* if (!config.apiKey) {
* throw new Error("OPENSEA_API_KEY is not configured.");
* }
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove

})
async listNFT(args: z.infer<typeof OpenSeaListNFTSchema>): Promise<string> {
try {
const expirationTime = Math.round(Date.now() / 1000 + 60 * 60 * 24);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the expiration be user-configurable?


return `Successfully listed NFT:\n${JSON.stringify(response)}`;
} catch (error) {
console.log("response: ", error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove

"OPENAI_API_KEY",
"CDP_API_KEY_NAME",
"CDP_API_KEY_PRIVATE_KEY",
"WALLET_PRIVATE_KEY",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove, see comment in openSeaActionProvider.ts

@@ -86,7 +92,7 @@ async function initializeAgent() {
apiKeyName: process.env.CDP_API_KEY_NAME,
apiKeyPrivateKey: process.env.CDP_API_KEY_PRIVATE_KEY?.replace(/\\n/g, "\n"),
cdpWalletData: walletDataStr || undefined,
networkId: process.env.NETWORK_ID || "base-sepolia",
networkId: process.env.NETWORK_ID || "ethereum-sepolia",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert – fallback value should remain base-sepolia

Comment on lines +108 to +110
openSeaActionProvider({
walletPrivateKey: process.env.WALLET_PRIVATE_KEY!,
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should an apiKey be passed in here?

@0xRAG 0xRAG added changes requested PR / Issue has changes requested typescript and removed needs review PR / issue needs review labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action provider New action provider apple changes requested PR / Issue has changes requested typescript
Development

Successfully merging this pull request may close these issues.

4 participants