Skip to content

Feat/opensea Integrate Opensea Actions to Agentkit - #325

Closed
Elkhan-Isayev wants to merge 5 commits into
coinbase:mainfrom
mahammadZeynalov:feat/opensea
Closed

Elkhan-Isayev wants to merge 5 commits into
coinbase:mainfrom
mahammadZeynalov:feat/opensea

Conversation

@Elkhan-Isayev

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

Copy link
Copy Markdown

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

cb-heimdall commented Feb 9, 2025 •

Copy link
Copy Markdown

🟡 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
2 if repo is sensitive 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
Copy Markdown
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
Copy Markdown
Author

Issue ticked id: #300

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

@0xRAG 0xRAG left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread package.json
"typescript": "^5.4.5"
},
"dependencies": {
"opensea-js": "^7.1.15"

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

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
Copy Markdown
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
Copy Markdown
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
@phdargen

phdargen commented Jul 25, 2025 •

Copy link
Copy Markdown
Contributor

Has been implemented in #261, can be closed @CarsonRoscoe together with issue #300

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.

5 participants