Skip to content

feat: add USDC send examples (AA + non-AA) across JS, Go, Python - #24

Open
Rshahatit wants to merge 1 commit into
mainfrom
rami/eng-7711-doc-5-add-usdc-examples-to-enclave-example-repo
Open

feat: add USDC send examples (AA + non-AA) across JS, Go, Python#24
Rshahatit wants to merge 1 commit into
mainfrom
rami/eng-7711-doc-5-add-usdc-examples-to-enclave-example-repo

Conversation

@Rshahatit

@Rshahatit Rshahatit commented Jun 19, 2026

Copy link
Copy Markdown

Summary

Resolves ENG-7711. The example repo previously only demonstrated native-token sends, which left customers hand-building ERC-20 transactions (see the linked support thread — the customer hit repeated "insufficient balance" errors). These examples use the enclave POST /v1/assets/send endpoint, which builds, signs, and broadcasts the transfer for you, and cover both account-abstraction and standard flows.

Each language demonstrates:

  • AA flow (sponsorGas omitted/true): Portal sponsors the gas. Requires an Account Abstraction client (isAccountAbstracted: true at signup). The wallet does not need to hold native tokens.
  • Non-AA flow (sponsorGas: false): a standard wallet pays its own gas and must hold the chain's native token — the exact "insufficient balance" gotcha from the support thread.

The token field uses the "USDC" shorthand (the enclave resolves it to the right ERC-20 per chain); a contract-address fallback is documented for chains where the shorthand isn't supported.

Changes

Language What Run
JavaScript Javascript/eth-send-assets.js generalized to send USDC (and any token) with AA/non-AA variants — folded into the existing assets/send example rather than a new file yarn sendUsdc / yarn sendUsdcSponsored
Go new Go/sendUsdc/sendUsdc.go + Go/cmd/sendUsdc/main.go make sendUsdc / make sendUsdcSponsored
Python new Python/send_usdc.py python send_usdc.py [sponsored]

READMEs updated in each folder with run steps for both flows, the native-gas requirement, and a Circle-faucet pointer.

Security hardening

The JS folder's .gitignore excluded clientApiKey.txt/shares.txt, but Go and Python did not — so anyone running those examples could have committed wallet credentials to this public repo. Added clientApiKey.txt, shares.txt, and backupShares.txt to both Go/.gitignore and Python/.gitignore.

Verification

Static checks: Go build/vet/gofmt, JS node --check, Python py_compile all pass.

Live end-to-end on Sepolia — all three languages confirmed on-chain:

  • JS non-AA: wallet paid its own gas, sent 1 USDC — real tx 0x064cc6…acc50 (status 1).
  • JS AA: sent USDC while holding 0 ETH → gas sponsored; smart account deployed on first send (UserOp).
  • Go AA: make sendUsdcSponsored — balance dropped on-chain (UserOp 0x2020d3…b5d4).
  • Python AA: python send_usdc.py sponsored — balance dropped on-chain (UserOp 0x845eeb…969d).

AA sends return a UserOperation hash (verify on a UserOp explorer like JiffyScan, not Etherscan). The non-AA path is the same code with sponsorGas: false, proven by the JS non-AA real tx above.

@Rshahatit
Rshahatit force-pushed the rami/eng-7711-doc-5-add-usdc-examples-to-enclave-example-repo branch from f1613bd to c13c814 Compare June 19, 2026 00:53
The example repo previously only demonstrated native-token sends, which left
customers hand-building ERC-20 transactions. Add USDC examples that use the
enclave `POST /v1/assets/send` endpoint (which builds, signs, and broadcasts
the transfer for you), each covering both flows:

- AA flow (sponsorGas omitted/true): Portal sponsors gas; requires an
  Account Abstraction client. Wallet does not need native tokens.
- Non-AA flow (sponsorGas: false): wallet pays its own gas and must hold the
  chain's native token (the common "insufficient balance" gotcha).

Changes:
- Javascript/eth-send-assets.js: generalized to send USDC (and any token) with
  AA/non-AA variants (+ yarn sendUsdc / sendUsdcSponsored)
- Go/sendUsdc/sendUsdc.go + Go/cmd/sendUsdc/main.go (+ make sendUsdc / sendUsdcSponsored)
- Python/send_usdc.py (python send_usdc.py [sponsored])

Also harden Go/Python .gitignore to exclude clientApiKey.txt, shares.txt, and
backupShares.txt (previously only the JS example ignored wallet credentials).

Verified end-to-end on Sepolia: non-AA send (real tx) and AA sponsored send
(UserOp, gas sponsored, smart account deployed) confirmed on-chain in all three
languages.

Ref: ENG-7711
@Rshahatit
Rshahatit force-pushed the rami/eng-7711-doc-5-add-usdc-examples-to-enclave-example-repo branch from c13c814 to a89d548 Compare June 22, 2026 18:55
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.

1 participant