Skip to content

Conversation

@0xRAG
Copy link
Contributor

@0xRAG 0xRAG commented Aug 8, 2025

Description

This PR implements two Spend Permissions actions in both EvmWallet and SmartWallet:

  • list_spend_permissions
  • use_spend_permissions

Tests

Setup:

  1. Used the createSpendPermission example script to create a spend permission for my Agent's wallet.

Transcript of chat with Vercel AI Chatbot

Prompt: print wallet details
print wallet details
Here are your wallet details:

- **Provider:** cdp_smart_wallet_provider
- **Address:** 0xe1D1D37231799d5784b12b0b53bB2866a99e8C18
- **Network:**
  - **Protocol Family:** EVM
  - **Network ID:** base-sepolia
  - **Chain ID:** 84532
- **Native Balance:** 0 WEI

If you need any further assistance, let me know!
-------------------

Prompt: print balance of erc20 token with address 0x036CbD53842c5426634e7929541eC2318f3dCF7e
print balance of erc20 token with address 0x036CbD53842c5426634e7929541eC2318f3dCF7e
The balance of the ERC20 token with address `0x036CbD53842c5426634e7929541eC2318f3dCF7e` is **0.005** tokens. If you need any further assistance, feel free to ask!
-------------------

Prompt: list spend permissions granted by 0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28
list spend permissions granted by 0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28
Here are the spend permissions granted by the smart account `0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28`:

1. **Token:** `0x036cbd53842c5426634e7929541ec2318f3dcf7e`
   - **Allowance:** 10,000 tokens
   - **Period:** 2,592,000 seconds (30 days)
   - **Start:** 1754666025 (Unix timestamp)
   - **End:** 281474976710655 (Unix timestamp)

If you need further assistance, let me know!
-------------------

Prompt: use 5000 of the spend permission granted by 0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28
use 5000 of the spend permission granted by 0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28
Successfully spent **5000 tokens** using the spend permission granted by the smart account `0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28`. The transaction status is currently broadcast. If you need any further assistance, feel free to ask!
-------------------

Prompt: print balance of erc20 token with address 0x036CbD53842c5426634e7929541eC2318f3dCF7e
print balance of erc20 token with address 0x036CbD53842c5426634e7929541eC2318f3dCF7e
The balance of the ERC20 token with address `0x036CbD53842c5426634e7929541eC2318f3dCF7e` is **0.01 tokens**. If you need any further assistance, let me know!
-------------------

Transcript of chat with Vercel AI Chatbot modified to use EVM Server Wallet

Prompt: print wallet details
print wallet details
Here are your wallet details:

- **Provider:** cdp_evm_wallet_provider
- **Address:** 0x81791fddB6fC4397DcE3E1031A159c2636A487Df
- **Network:**
  - **Protocol Family:** EVM
  - **Network ID:** base-sepolia
  - **Chain ID:** 84532
- **Native Balance:** 0 WEI

If you need any further assistance, let me know!
-------------------

Prompt: list spend permissions granted by 0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28
list spend permissions granted by 0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28
Here are the spend permissions granted by the smart account `0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28`:

1. **Token:** `0x036cbd53842c5426634e7929541ec2318f3dcf7e`
   - **Allowance:** 10,000
   - **Period:** 2,592,000 seconds (30 days)
   - **Start Time:** 1754687882
   - **End Time:** 281474976710655

If you need further assistance, feel free to ask!
-------------------

Prompt: print erc20 balance of token 0x036cbd53842c5426634e7929541ec2318f3dcf7e
print erc20 balance of token 0x036cbd53842c5426634e7929541ec2318f3dcf7e
The ERC20 balance of the token `0x036cbd53842c5426634e7929541ec2318f3dcf7e` is **0**. If you need any further assistance, let me know!
-------------------

Prompt: use 5000 of spend permission granted by 0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28
use 5000 of spend permission granted by 0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28

-------------------

Prompt: faucet some eth
faucet some eth
I have successfully received ETH from the faucet. The transaction hash is: **0x390b1ce76cc346dfa5a0fd39ce13d03559567b835e8806eea6ae0b3be956fd09**.

If you need any further assistance, feel free to ask!
-------------------

Prompt: use 5000 of spend permission granted by 0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28
use 5000 of spend permission granted by 0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28
I have successfully used 5000 tokens from the spend permission granted by `0x2017C472CeB2f9A8Bb3d909B0E2ADD46805dDd28`. The transaction hash is: **0x8262653528f58176910163e21a8dddf94d7b040b42485fba6f052d628af603e4**.

If you need any further assistance, feel free to ask!
-------------------

Prompt: print erc20 balance of token 0x036cbd53842c5426634e7929541ec2318f3dcf7e
print erc20 balance of token 0x036cbd53842c5426634e7929541ec2318f3dcf7e
The ERC20 balance of the token `0x036cbd53842c5426634e7929541ec2318f3dcf7e` is **0.005**. If you need any further assistance, let me know!
-------------------

Note: There was a slight hiccup where the agent seemed to not respond after the first time requesting to use the spend permission. This is because it didn't have funds to cover gas. The reason it didn't print anything is because the action was throwing an error instead of returning a string – this has since been fixed.

Checklist

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

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

@linear
Copy link

linear bot commented Aug 8, 2025

@cb-heimdall
Copy link

cb-heimdall commented Aug 8, 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
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 0
Sum 1

@github-actions github-actions bot added action provider New action provider wallet provider New wallet provider example New example agent typescript labels Aug 8, 2025
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Aug 8, 2025
@0xRAG 0xRAG force-pushed the AGENT-329 branch 3 times, most recently from b8a30ca to 280d0c3 Compare August 8, 2025 21:47
@0xRAG 0xRAG marked this pull request as ready for review August 8, 2025 21:51
@0xRAG 0xRAG requested a review from murrlincoln as a code owner August 8, 2025 21:51
* A wallet provider that uses the Coinbase CDP SDK smart wallets.
*/
export class CdpSmartWalletProvider extends EvmWalletProvider implements WalletProviderWithClient {
public smartAccount: EvmSmartAccount;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally I think this is fine because the smartAccount provides lots of convenience methods, in particular .useSpendPermission which is used in this PR. Other convenience methods may be used in future actions (like .swap – cc @phdargen re: fix: swap api)

/**
* Lists spend permissions for a smart account.
*
* @param walletProvider - The server wallet provider to use for listing permissions.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we add context on how these spend permissions can be created?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. Will follow up with Ryan and fast-follow with the info

@CarsonRoscoe CarsonRoscoe merged commit bc3d1d5 into main Aug 9, 2025
30 checks passed
@CarsonRoscoe CarsonRoscoe deleted the AGENT-329 branch August 9, 2025 15:27
@phdargen phdargen mentioned this pull request Aug 12, 2025
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action provider New action provider 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.

5 participants