Skip to content

CLI: run wallet ERC-20 interactions on the SDK's erc20Actions (stacked on #23) - #35

Merged
kylecrawshaw merged 1 commit into
mainfrom
claude/cli-erc20-actions
Sep 30, 2026
Merged

kylecrawshaw merged 1 commit into
mainfrom
claude/cli-erc20-actions

Conversation

@kylecrawshaw

@kylecrawshaw kylecrawshaw commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Stacked on #24 (SDK Permit2 actions), itself on #23 (SDK ERC-20 actions). Review only the last commit; the base branches carry the SDK work. #36, stacked on this PR, adds the new ERC-20 commands.

What

The CLI's existing ERC-20 code paths run on radius-sdk/client instead of a hand-written ABI in wallet.ts. No new commands here.

  • lib/client.ts: makePublicClient extends with radiusActions + erc20Actions, makeWalletClient with erc20Actions, both defaulting to the configured SBC contract (--sbc / RADIUS_SBC_ADDRESS, else the canonical address from the SDK).
  • lib/erc20.ts (new): token argument parsing (SBC or any 0x address), display-amount parsing and readBalances.
  • wallet send <to> <amount> SBC goes through the SDK's transfer; wallet send <to> <amount> 0xToken transfers any ERC-20, with decimals read on-chain. --gas-limit still works via the gas option added to the SDK write actions in SDK: common ERC-20 interactions (stacked on #22) #23. The receipt is awaited by the CLI so --no-wait and the {hash, receipt} output are unchanged.
  • wallet balance uses the SDK's getBalances. Previously it added SBC on top of eth_getBalance, which on Radius already includes SBC 1:1, so totalUsd double counted. rusd is now native RUSD only, and the JSON gains aggregateWei and rusdSource (evm / derived / aggregate when the SBC read failed and the aggregate is all we have). The CLI half of Add balance query APIs accounting for Radius stablecoin aggregation #22 that described this never landed.

Not touched: wallet x402's Permit2 approval, which stays on createRadiusFetch().approvePermit2() (see #24).

Tests

tests/erc20.test.ts covers token/amount parsing and readBalances against an in-memory node that models Radius' aggregated eth_getBalance (both the separated read and the fallback when balanceOf fails). CLI total 31 passing, pnpm build clean. Not run against a live node.

ENG-2276

🤖 Generated with Claude Code

@kylecrawshaw
kylecrawshaw force-pushed the claude/cli-erc20-actions branch from 7eba33e to ce9cdea Compare September 23, 2026 19:22
@kylecrawshaw
kylecrawshaw force-pushed the claude/cli-erc20-actions branch 2 times, most recently from 1ea17c5 to 3836049 Compare September 23, 2026 19:31
@kylecrawshaw
kylecrawshaw changed the base branch from claude/charming-carson-hr92hc-erc20 to claude/charming-carson-hr92hc-permit2 September 23, 2026 19:31
@kylecrawshaw
kylecrawshaw added this pull request to stack #32 September 23, 2026 19:32
azf20
azf20 previously approved these changes Sep 24, 2026
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: ef215c4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
radius-cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kylecrawshaw
kylecrawshaw force-pushed the claude/cli-erc20-actions branch from 3095a29 to 8a55584 Compare September 25, 2026 13:59
Base automatically changed from claude/charming-carson-hr92hc-permit2 to main September 30, 2026 20:23
`makePublicClient` / `makeWalletClient` extend their viem clients with
`radiusActions` and `erc20Actions` from `radius-sdk/client`, defaulting to the
configured SBC contract. `wallet send … SBC` goes through the SDK's `transfer`
(amount parsing, calldata, `--gas-limit` via `gas`), and any 0x token address
works in the same position, with decimals read on-chain.

`wallet balance` now uses the SDK's `getBalances`, which keeps native RUSD apart
from SBC instead of adding SBC on top of the aggregate `eth_getBalance` that
already includes it. The JSON gains `aggregateWei` and `rusdSource`. The hand-
written ERC-20 ABI in wallet.ts is gone.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@kylecrawshaw
kylecrawshaw force-pushed the claude/cli-erc20-actions branch from 8a55584 to ef215c4 Compare September 30, 2026 20:23

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

👍🏻

@kylecrawshaw
kylecrawshaw merged commit ba3f6c1 into main Sep 30, 2026
4 checks passed
@kylecrawshaw
kylecrawshaw deleted the claude/cli-erc20-actions branch September 30, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants