Skip to content

feat: add action to list nfts on opensea (ts) - #261

Merged
CarsonRoscoe merged 6 commits into
coinbase:mainfrom
phdargen:opensea-ts
Mar 5, 2025
Merged

CarsonRoscoe merged 6 commits into
coinbase:mainfrom
phdargen:opensea-ts

Conversation

@phdargen

@phdargen phdargen commented Feb 5, 2025

Copy link
Copy Markdown
Contributor

Why? What?

Adds new OpenseaActionProvider to handle interactions with opensea.
So far only one action is implemented (list_nft) that creates a listing on opensea.
Additional actions like accept/create offer may be added in the future.

This implementation uses the opensea-js sdk that is added as new dependency and requires an opensea api key (https://docs.opensea.io/reference/api-overview). The new action is added in the chatbot.ts example, only if an OPENSEA_API_KEY is set.

The OpenSea SDK requires an ethers signer which is created when initialising OpenseaActionProvider with the privateKey to the account holding the NFT. In the chatbot.ts example, I extract the privateKey from the CdpWalletProvider. This is a bit of a hack but I couldn't find a way to directly use a EvmWalletProvider to create a ethers signer. Suggestions are welcome.

What changed?

Network support

  • Base
  • Base Sepolia
  • (Should be easy to extend to further evm networks)

Checklist

  • Changelog updated
  • Rebased against master

How has it been tested?

  • Unit tests
  • Agent tested, example prompt below (using gpt-4o-mini)
Prompt: deploy nft and mint to your wallet, decide all details

-------------------
Deployed NFT Collection My Unique NFT Collection:
- to address 0xFF145576D6266AEd8BD70172210d8ACa52CA236a
- on network base-sepolia.
Transaction hash: 0x70f5bf1be168238a5b70b630462fb1de6e493fa89ecb982616a9ffd774e162e0
Transaction link: https://sepolia.basescan.org/tx/0x70f5bf1be168238a5b70b630462fb1de6e493fa89ecb982616a9ffd774e162e0
-------------------
-------------------
Successfully minted NFT 0xFF145576D6266AEd8BD70172210d8ACa52CA236a to 0x51CD6e4d10F0282f48d13f4290960bF37f5eF151
-------------------
-------------------
The NFT collection "My Unique NFT Collection" has been successfully deployed with the symbol "MUNC". Here are the details:

- **NFT Contract Address**: [0xFF145576D6266AEd8BD70172210d8ACa52CA236a](https://sepolia.basescan.org/tx/0x70f5bf1be168238a5b70b630462fb1de6e493fa89ecb982616a9ffd774e162e0)  
- **Transaction Hash**: 0x70f5bf1be168238a5b70b630462fb1de6e493fa89ecb982616a9ffd774e162e0  
- **Network**: Base Sepolia  

Additionally, an NFT has been successfully minted to your wallet. If you need any further assistance, let me know!
-------------------

Prompt: list this nft with tokenid 0 for 1 eth on opensea

-------------------
Successfully listed NFT 0xFF145576D6266AEd8BD70172210d8ACa52CA236a token 0 for 1 ETH, expiring in 90 days. Listing on OpenSea: https://testnets.opensea.io/assets/base_sepolia/0xFF145576D6266AEd8BD70172210d8ACa52CA236a/0.
-------------------
The NFT with token ID `0` has been successfully listed for **1 ETH** on OpenSea. Here are the details:

- **Listing Link**: [View Listing on OpenSea](https://testnets.opensea.io/assets/base_sepolia/0xFF145576D6266AEd8BD70172210d8ACa52CA236a/0)
- **Expiration**: 90 days

@cb-heimdall

cb-heimdall commented Feb 5, 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
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 0
Sum 1

@phdargen

phdargen commented Feb 7, 2025

Copy link
Copy Markdown
Contributor Author

The EstimateGasExecutionError bug was also fixed in #283.
Will rebase after first review.

Comment thread typescript/agentkit/src/action-providers/opensea/openseaActionProvider.ts Outdated
@phdargen

phdargen commented Feb 9, 2025

Copy link
Copy Markdown
Contributor Author

I improved the provider setup such that a default provider is used and a private key is sufficient to setup OpenseaActionProvider

@John-peterson-coinbase

Copy link
Copy Markdown
Contributor

@phdargen please rebase onto latest master. The changes to action provider initialization LGTM

@phdargen

Copy link
Copy Markdown
Contributor Author

@phdargen please rebase onto latest master. The changes to action provider initialization LGTM

@John-peterson-coinbase Done!

@0xRAG 0xRAG added in review PR / issue is in review typescript needs review PR / issue needs review and removed changes requested PR / Issue has changes requested in review PR / issue is in review labels Feb 13, 2025
@phdargen
phdargen force-pushed the opensea-ts branch 2 times, most recently from 427113e to ef92687 Compare February 17, 2025 00:53
@phdargen

Copy link
Copy Markdown
Contributor Author

@murrlincoln please let me know when you had the time to review, then I will rebase again if needed (seems things are moving quickly)

Comment thread typescript/agentkit/src/action-providers/opensea/README.md

@CarsonRoscoe CarsonRoscoe 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.

Please rebase against main, there have been a lot of changes over the last two weeks. I want to make sure it's up to date for my testing

Comment thread typescript/agentkit/src/action-providers/opensea/openseaActionProvider.ts Outdated
Comment thread typescript/agentkit/src/action-providers/opensea/openseaActionProvider.ts Outdated

@CarsonRoscoe CarsonRoscoe 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.

One feature #325 had over this was its get_nfts_by_account action. I believe it is good for the agent to be able to read the NFTs.

Can you give your action provider the ability to read an accounts NFT holdings? I believe the action is just wrapping getNFTsByAccount function from the SDK's API

@github-actions github-actions Bot added documentation Improvements or additions to documentation wallet provider New wallet provider example New example agent needs triage labels Mar 4, 2025
Comment thread typescript/agentkit/CHANGELOG.md Outdated
@phdargen

phdargen commented Mar 4, 2025

Copy link
Copy Markdown
Contributor Author

get_nfts_by_account

Added get_nfts_by_account action and tests. Also tested successfully with prompt.

@CarsonRoscoe CarsonRoscoe 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.

LGTM!

Thank you for the quick work. This is great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action provider New action provider banana documentation Improvements or additions to documentation example New example agent needs review PR / issue needs review typescript wallet provider New wallet provider

Development

Successfully merging this pull request may close these issues.

5 participants