Skip to content

Expose public client for chain via Actions SDK#352

Closed
its-applekid wants to merge 3 commits into
ethereum-optimism:mainfrom
its-applekid:feature/expose-public-client
Closed

Expose public client for chain via Actions SDK#352
its-applekid wants to merge 3 commits into
ethereum-optimism:mainfrom
its-applekid:feature/expose-public-client

Conversation

@its-applekid
Copy link
Copy Markdown

Summary

Closes #232

Exposes the internal ChainManager.getPublicClient() method through the Actions class, allowing SDK consumers to access viem PublicClient instances for making on-chain calls without creating their own clients.

Motivation

As noted in #230 (discussion), developers currently need to manually create public clients with createPublicClient() to interact with on-chain contracts, even though the Actions SDK already manages properly configured clients internally. This leads to duplicated client creation logic and potentially misconfigured transports.

Changes

  • packages/sdk/src/actions.ts: Added getPublicClient(chainId) method that delegates to ChainManager
  • packages/sdk/src/index.ts: Re-exported PublicClient type from viem for consumer convenience
  • packages/sdk/src/__tests__/actions.test.ts: Added unit tests for the new method:
    • Returns PublicClient for configured chain
    • Throws error for unsupported chain
    • Returns same cached instance on repeated calls
    • Integration test: makes real on-chain call (external test)

Usage

const actions = new Actions(config, deps)

// Get a public client for Optimism
const publicClient = actions.getPublicClient(10)

// Use it for on-chain calls
const blockNumber = await publicClient.getBlockNumber()
const balance = await publicClient.getBalance({ address: '0x...' })

Testing

  • Build: ✅
  • Lint: ✅ (0 errors)
  • Tests: ✅ (442 passed, 11 skipped)

@its-applekid its-applekid requested a review from a team as a code owner April 1, 2026 20:09
@its-applekid its-applekid requested a review from jefr90 April 1, 2026 20:09
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 1, 2026

👷 Deploy request for actions-ui pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 1e02b02

@jefr90
Copy link
Copy Markdown
Contributor

jefr90 commented May 15, 2026

Thanks. Closing this for now: we haven't landed on a clear consumer use case for exposing the public client directly via the SDK. Happy to revisit when there's a concrete reason to surface it.

@jefr90 jefr90 closed this May 15, 2026
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.

Expose a way to get public client for a chain via the actions sdk

2 participants