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

Add support for Privy embedded wallets with delegation #583

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

Conversation

njokuScript
Copy link

@njokuScript njokuScript commented Mar 17, 2025

Add support for Privy embedded wallets with delegation

Description

This PR adds support for Privy's embedded wallets with delegation to AgentKit. It introduces a new wallet provider, PrivyEvmEmbeddedWalletProvider, that allows AgentKit to use wallets which have been delegated transaction signing authority through Privy's embedded wallet system. This enables autonomous agents to perform onchain actions on behalf of users.

The implementation:

  • Creates a new PrivyEvmEmbeddedWalletProvider class that extends EvmWalletProvider
  • Updates the PrivyWalletProvider factory to support embedded wallets via a new walletType option
  • Adds comprehensive test coverage for the new provider
  • Updates documentation on how to use the embedded wallet provider

Currently our UI uses Privy's embedded wallet for delegation to agents, but Coinbase's agent kit only supports Privy's server wallet. This change makes the two systems compatible, allowing agents to properly execute transactions with delegated embedded wallets.

Tests

Current network: { protocolFamily: 'evm', networkId: 'base', chainId: '8453' }
Agent initialized with wallet address: 0xc0A6A6D543Bdcf2fa4f4e390154F124A0B289969
Starting chat mode... Type 'exit' to end.

Prompt: send $2 worth of eth to 0xa0680AcC8F180d18441914eE0510996234B66259

-------------------
Wallet Details:
- Provider: privy_evm_embedded_wallet_provider
- Address: 0xc0A6A6D543Bdcf2fa4f4e390154F124A0B289969
- Network:
  * Protocol Family: evm
  * Network ID: base
  * Chain ID: 8453
- Native Balance: 22805689068594859 WEI
-------------------
Your wallet has a native balance of approximately 0.0228 ETH (22,805,689,068,594,859 WEI), which is more than enough to cover a $2 transfer.

However, I need to convert $2 to ETH based on the current ETH price. Let's fetch the latest price of ETH before proceeding with the transaction. 

I'll fetch the price now.
-------------------
ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
-------------------

-------------------
2046.31
-------------------

-------------------
Transferred 0.0000097 ETH to 0xa0680AcC8F180d18441914eE0510996234B66259
Transaction hash: 0xf92ce2c753b964edf46807979d8602c21f6e6188e38ec6e3c00e9d9ccdfd8b78
-------------------
I have successfully transferred approximately $2 worth of ETH (0.0000097 ETH) to the address **0xa0680AcC8F180d18441914eE0510996234B66259**. The transaction hash is **0xf92ce2c753b964edf46807979d8602c21f6e6188e38ec6e3c00e9d9ccdfd8b78**.
-------------------

Checklist

  • Added documentation to the PrivyWalletProvider section in README.md
  • Added a changelog entry in .changeset/privy-embedded-wallet.md

@cb-heimdall
Copy link

cb-heimdall commented Mar 17, 2025

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/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

@github-actions github-actions bot added documentation Improvements or additions to documentation wallet provider New wallet provider typescript labels Mar 17, 2025
@github-actions github-actions bot added the example New example agent label Mar 19, 2025
@njokuScript njokuScript marked this pull request as ready for review March 19, 2025 00:08
apiKeyName: process.env.CDP_API_KEY_NAME as string,
apiKeyPrivateKey: process.env.CDP_API_KEY_PRIVATE_KEY as string,
}),
cdpWalletActionProvider({
Copy link
Contributor

Choose a reason for hiding this comment

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

cdpWalletActionProider only works with CdpWalletProvider. It is not expected that this would work with other wallet providers.

Copy link
Author

Choose a reason for hiding this comment

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

cdpWalletActionProider only works with CdpWalletProvider. It is not expected that this would work with other wallet providers.

got it. makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apple documentation Improvements or additions to documentation example New example agent typescript wallet provider New wallet provider
Development

Successfully merging this pull request may close these issues.

4 participants