Skip to content

Feature Request: Allow state wallet to sign state while user wallet sends transaction #78

Description

@cqlyj

Problem

The SDK does not support the common state channel pattern where:

  • state wallet signs the off-chain state (e.g., channel creation)
  • user wallet sends the on-chain transaction (pays gas)

Currently, createChannel does not expose a way to separate these roles. This leads to contract signature errors or prevents best-practice separation of keys.

Example (Desired Usage)

const client = new NitroliteClient({
  publicClient,
  walletClient, // p1: user wallet (sends tx)
  stateWalletClient, // p2: state wallet (signs state)
  chainId,
  addresses,
});

await client.createChannel({
  initialAllocationAmounts: [BigInt(100), BigInt(0)],
  stateData: "0x",
});
// Expectation: p2 signs the state, p1 sends the transaction

Expected

  • SDK should always use stateWalletClient for state signing (if provided), and walletClient for sending transactions.

Why

  • This is standard in state channel protocols
  • Needed for security and protocol compliance

Suggestion

  • Update SDK to support this pattern and document it with an example.

Activity

  1. cqlyj commented on May 21, 2025

    @cqlyj
    Author

    Btw I find that the interface for createChannel params are different in docs and this sdk:

    In the docs it's like:

    const channelParams = {
      participants: participants, // [your address, ClearNode address]
      amounts: [depositAmount, 0n], // Initial allocation (you: 100 USDC, ClearNode: 0)
      tokenAddress: client.addresses.tokenAddress, // USDC token address (from client config)
      challengePeriod: client.challengeDuration, // Use default from client config
      nonce: BigInt(Date.now()), // Unique channel identifier
    };

    However in the current sdk, the interface is still:

    export interface CreateChannelParams {
        initialAllocationAmounts: [bigint, bigint];
        stateData?: Hex;
    }
    

    Perhaps some updates are required here.

  2. akushniruk commented on May 22, 2025

    @akushniruk
    Contributor

    @cqlyj Thank you for your finding

    Yes, you're right about stateWalletClient. And about documentation, we will update it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions