Skip to content

Add support for Privy embedded wallets with delegation - #618

Merged
CarsonRoscoe merged 15 commits into
mainfrom
feat/privy-evm-delegated-embedded-wallet-provider
Mar 28, 2025
Merged

Add support for Privy embedded wallets with delegation#618
CarsonRoscoe merged 15 commits into
mainfrom
feat/privy-evm-delegated-embedded-wallet-provider

Conversation

@CarsonRoscoe

@CarsonRoscoe CarsonRoscoe commented Mar 27, 2025

Copy link
Copy Markdown
Contributor

This PR is a continuation of #583

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

See original authors tests here: #583

Below are my own tests in addition to the above:

Prompt: Do a native transfer, using the value 0.00001 ETH, and transfer to 0x13f2344Df67CB87f5f6C4809f396696c839e0A5A. Do not convert that number, pass in exactly 0.00001 sas the value

-------------------
Wallet Details:
- Provider: privy_evm_embedded_wallet_provider
- Address: 0xc342103DA49ed761C555f58fE336C8E7Ef2d587a
- Network:
  * Protocol Family: evm
  * Network ID: base-sepolia
  * Chain ID: 84532
- Native Balance: 199612217380681 WEI
-------------------

-------------------
Transferred 0.00001 ETH to 0x13f2344Df67CB87f5f6C4809f396696c839e0A5A
Transaction hash: 0x8da3cd3a39148e63da57c211d240bb2e39925177b147fb5d0e0cf92dd0256e11
-------------------
Successfully transferred **0.00001 ETH** to **0x13f2344Df67CB87f5f6C4809f396696c839e0A5A**. 

Transaction hash: **0x8da3cd3a39148e63da57c211d240bb2e39925177b147fb5d0e0cf92dd0256e11**.
-------------------

Prompt: faucet USDC
The faucet is only available on the 'base-sepolia' network for the assets 'eth' or 'usdc'. Since we are currently on the 'base-sepolia' network, I can request USDC for you.

Let's proceed with requesting USDC from the faucet.
-------------------
Received usdc from the faucet. Transaction: https://sepolia.basescan.org/tx/0xda803c3c2c5e906fd7b8344713149adc34bdea2f854cf0922058dcd185e7eb46
-------------------
Successfully received **USDC** from the faucet. You can view the transaction details [here](https://sepolia.basescan.org/tx/0xda803c3c2c5e906fd7b8344713149adc34bdea2f854cf0922058dcd185e7eb46).
-------------------

Prompt: Send 0.5 USDC (500000 units, contract address 0x036CbD53842c5426634e7929541eC2318f3dCF7e) to 0x13f2344Df67CB87f5f6C4809f396696c839e0A5A

-------------------
Transferred 500000 of 0x036CbD53842c5426634e7929541eC2318f3dCF7e to 0x13f2344Df67CB87f5f6C4809f396696c839e0A5A.
Transaction hash for the transfer: 0xd7c6e98efc2a85eaf583be31adbd47453ccb62481c09d912a823efd472175883
-------------------
Successfully transferred **0.5 USDC** (500,000 units) to **0x13f2344Df67CB87f5f6C4809f396696c839e0A5A**.

Transaction hash: **0xd7c6e98efc2a85eaf583be31adbd47453ccb62481c09d912a823efd472175883**.

Checklist

A couple of things to include in your PR for completeness:

  • Added documentation to all relevant README.md files
  • Added a changelog entry

@cb-heimdall

cb-heimdall commented Mar 27, 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

@github-actions github-actions Bot added documentation Improvements or additions to documentation wallet provider New wallet provider example New example agent typescript labels Mar 27, 2025
@CarsonRoscoe CarsonRoscoe changed the title Add support for Privy embedded wallets with delegation (#583) Add support for Privy embedded wallets with delegation Mar 27, 2025
@CarsonRoscoe
CarsonRoscoe marked this pull request as ready for review March 27, 2025 18:06
@CarsonRoscoe
CarsonRoscoe requested a review from 0xRAG March 27, 2025 18:07
@CarsonRoscoe
CarsonRoscoe force-pushed the feat/privy-evm-delegated-embedded-wallet-provider branch from 7952a38 to e1b0a67 Compare March 27, 2025 22:42
njokuScript and others added 10 commits March 28, 2025 10:51
* chore: implement privy delegated wallet provider for evm

* chore: rename provider to be evm specific

* add unused func to fix inheritance error

* chore: add tests for privy evm embedded wallet provider

* update readme and changeset

* fix onchain spelling

* chore: Changed the parameter structure to accept a single config object with address and add example

* chore: export privy client from shared privy class

* chore: fix native assets transfer

* uncomment analytics event

* remove logs and use viem's Adress type

* use viem's Hex type

* lookup chain ID using global NETWORK_ID_TO_CHAIN_ID

* remove unused chainid mapping fnc

* fix(wallet-providers): Fix type casting in PrivyWalletProvider

* remove unnecessary comments

* delete lock files

* chore: remove logs

* chore: await response from privy provider variant

* chore: rename spelling to privyEvmDelegatedEmbeddedWalletProvider

* udpate chatbot example to use new naming and add env.local file
…is merged, and add to privyWalletProvider tests
@CarsonRoscoe
CarsonRoscoe force-pushed the feat/privy-evm-delegated-embedded-wallet-provider branch from e1b0a67 to fc2fa73 Compare March 28, 2025 14:51
@CarsonRoscoe
CarsonRoscoe force-pushed the feat/privy-evm-delegated-embedded-wallet-provider branch from 7f299d3 to 0a2f2b5 Compare March 28, 2025 15:51
Comment thread typescript/.changeset/privy-evm-embedded-wallet.md Outdated
Comment thread typescript/.changeset/privy-evm-embedded-wallet.md Outdated
Comment thread typescript/.changeset/privy-evm-embedded-wallet.md Outdated
Comment thread typescript/.changeset/privy-evm-embedded-wallet.md Outdated
Comment thread typescript/agentkit/README.md Outdated
Comment thread typescript/agentkit/src/wallet-providers/privyShared.ts
@CarsonRoscoe
CarsonRoscoe force-pushed the feat/privy-evm-delegated-embedded-wallet-provider branch from 6a40b6e to 774fbb4 Compare March 28, 2025 19:34
@CarsonRoscoe
CarsonRoscoe requested a review from 0xRAG March 28, 2025 19:39

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

LGTM

@CarsonRoscoe
CarsonRoscoe merged commit 155d468 into main Mar 28, 2025
@CarsonRoscoe
CarsonRoscoe deleted the feat/privy-evm-delegated-embedded-wallet-provider branch March 28, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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