Skip to content

Conversation

@phdargen
Copy link
Contributor

@phdargen phdargen commented Sep 4, 2025

Description

Fixes issues for native/erc20 balance actions reported by @Story91:

  • get_wallet_details returns ETH amount in wei, LLM converts this to whole units in message to user. Result of conversion depends on LLM knowledge, gpt-4o-mini always got it wrong in my tests
    -> get_wallet_details returns now both amount in wei and whole units

  • when several erc20 token balances are queried in one prompt, default rpc might throw error due to rate limits
    -> made rpc calls more efficient using multicall

  • when prompting eg "fetch usdc balance", LLM often hallucinates address (for example taking usdc address from mainnet, not base)
    -> refined action description + added new action to retrieve commonly used token addresses by symbol for given network

In addition, the following improvements are made:

  • WalletActionProvider native_transfer takes amount in whole units as input and passes this to walletProviders. However, most of them expect atomic units instead -> this is now handled consistently as follows: action takes whole unit format as input, converts to atomic units and then calls internal native_transfer from walletProviders with that
  • remove hardcoded erc20 abi in favor of viem export
  • added guardrails for erc20 transfers to prevent loss of funds by sending to token contracts
  • added optional address arg (default to wallet address) to get_balance erc20 action
  • fixed examples/langchain-cdp-chatbot /chatbot.ts to correctly configure CdpSolanaWalletProvider
  • fixed native sol transfers for CdpSolanaWalletProvider that was throwing Error during transfer: Error: Signature must be 64 bytes long

Tests

Chatbot: typescript/examples/langchain-cdp-chatbot/chatbot.ts
Network: Base mainnet

Prompt: wallet info

-------------------
Wallet Details:
- Provider: cdp_evm_wallet_provider
- Address: 0xf2d4580ADfe8E012f5550322706d62DF11fDBE21
- Network:
  * Protocol Family: evm
  * Network ID: base-mainnet
  * Chain ID: 8453
- Native Balance: 411444858090719 WEI
- Native Balance: 0.000411444858090719 ETH
-------------------
Here are the details of your wallet:

- **Address:** 0xf2d4580ADfe8E012f5550322706d62DF11fDBE21
- **Provider:** cdp_evm_wallet_provider
- **Network:**
  - **Protocol Family:** EVM
  - **Network ID:** base-mainnet
  - **Chain ID:** 8453
- **Native Token Balance:** 0.000411444858090719 ETH
-------------------

Prompt: fetch usdc and cbbtc balance

-------------------
Token address for USDC on base-mainnet: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
-------------------

-------------------
Balance of USD Coin (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) at address 0xf2d4580ADfe8E012f5550322706d62DF11fDBE21 is 0.231121
-------------------
Here are your balances for USDC and CBBTC:

- **USDC Balance:** 0.231121 USDC
- **CBBTC Balance:** 0.00000024 CBBTC

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

Prompt: check bankr balance

-------------------
Error: Token symbol "BANKR" not found on base-mainnet. Available token symbols on base-mainnet: USDC, EURC, CBBTC, CBETH, WETH, ZORA, AERO, BNKR, CLANKER
-------------------

-------------------
Token address for BNKR on base-mainnet: 0x22af33fe49fd1fa80c7149773dde5890d3c76f3b
-------------------

-------------------
Balance of BankrCoin (0x22af33fe49fd1fa80c7149773dde5890d3c76f3b) at address 0xf2d4580ADfe8E012f5550322706d62DF11fDBE21 is 0
-------------------
Your balance for BankrCoin (BNKR) is **0**. If you need assistance with anything else, feel free to ask!
-------------------

Prompt: send 0.001 usdc to 0xa8c1a5D3C372C65c04f91f87a43F549619A9483f
Transferred 0.001 of USD Coin (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) to 0xa8c1a5D3C372C65c04f91f87a43F549619A9483f.
Transaction hash for the transfer: 0xfc070337f72b5e154e556d007efc6418ff8c74bcc29c087107e07efdcc16daf2
-------------------
I have successfully transferred **0.001 USDC** to the address **0xa8c1a5D3C372C65c04f91f87a43F549619A9483f**. 

The transaction hash is: **0xfc070337f72b5e154e556d007efc6418ff8c74bcc29c087107e07efdcc16daf2**.

If you need anything else, just let me know!
-------------------

Prompt: send 0.000001 eth to 0xa8c1a5D3C372C65c04f91f87a43F549619A9483f

-------------------
Transferred 0.000001 ETH to 0xa8c1a5D3C372C65c04f91f87a43F549619A9483f
Transaction hash: 0xeafcac9aa1beb05a2dd72362741939287b6b951ef70a96de38252d5270b08221
-------------------
I have successfully transferred **0.000001 ETH** to the address **0xa8c1a5D3C372C65c04f91f87a43F549619A9483f**.

The transaction hash is: **0xeafcac9aa1beb05a2dd72362741939287b6b951ef70a96de38252d5270b08221**.

Prompt: check usdc balance for 0xa8c1a5D3C372C65c04f91f87a43F549619A9483f

----------
Balance of USD Coin (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) at address 0xa8c1a5D3C372C65c04f91f87a43F549619A9483f is 9.076885
-------------------
The balance of USDC for the address **0xa8c1a5D3C372C65c04f91f87a43F549619A9483f** is **9.076885 USDC**.
Chatbot: typescript/examples/langchain-cdp-chatbot/chatbot.ts
Network: Solana devnet

Prompt: send 0.0001 sol to 91sEBA6DLKakGV4raqW2pE8bmQR1D9dnbdGTjtATur5U 

-------------------
Transferred 0.0001 SOL to 91sEBA6DLKakGV4raqW2pE8bmQR1D9dnbdGTjtATur5U
Signature: 45MJKkm5CEQbCED8s7Ykz8P8bFySyqXq8AoLWzXW2NXUMMWwW2hcUs22yux1M9q5RHvcUGvcVbgHyy3sHGVC6CyM
-------------------
The transfer of 0.0001 SOL to the address **91sEBA6DLKakGV4raqW2pE8bmQR1D9dnbdGTjtATur5U** has been successfully completed. 

Transaction Signature: **45MJKkm5CEQbCED8s7Ykz8P8bFySyqXq8AoLWzXW2NXUMMWwW2hcUs22yux1M9q5RHvcUGvcVbgHyy3sHGVC6CyM**

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

cb-heimdall commented Sep 4, 2025

✅ Heimdall Review Status

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

@phdargen phdargen marked this pull request as draft September 4, 2025 03:39
@github-actions github-actions bot added action provider New action provider wallet provider New wallet provider typescript documentation Improvements or additions to documentation labels Sep 4, 2025
@phdargen phdargen marked this pull request as ready for review September 4, 2025 04:20
@phdargen phdargen force-pushed the fixBalanceFormat branch 2 times, most recently from 532bc67 to c2857a8 Compare September 4, 2025 04:40
@github-actions github-actions bot added the example New example agent label Sep 4, 2025
Copy link
Contributor

@CarsonRoscoe CarsonRoscoe left a comment

Choose a reason for hiding this comment

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

Fantastic work, ty! Lots of little chores we've been meaning to get to all wrapped up in one nice package

@CarsonRoscoe CarsonRoscoe merged commit 5e133ea into coinbase:main Sep 5, 2025
26 checks passed
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.

4 participants