Skip to content

Conversation

@rajgoesout
Copy link

Export plural versions of useSignTransaction and useSignAndSendTransaction.

Problem

Wallet-standard allows requesting a wallet to sign multiple transactions. But we only export a hook capable of signing one, eg useSignTransaction.

The actual implementation of this uses a hook that can accept multiple transactions.

Summary of Changes

  • Exposed useSignTransactions and useSignAndSendTransactions as public React hooks.
  • Expanded unit/type tests to cover multi-transaction, empty-input, and chain-validation cases.
  • Updated docs/examples.

Closes #1104

Export plural versions of useSignTransaction and useSignAndSendTransaction.

Closes anza-xyz#1104
@changeset-bot
Copy link

changeset-bot bot commented Dec 6, 2025

⚠️ No Changeset found

Latest commit: 1f6f571

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@rajgoesout rajgoesout marked this pull request as ready for review December 8, 2025 04:42
Copy link
Collaborator

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

Before we move forward, lets think about whether wallets are ready to handle multi-signing workflows from a UI perspective. Right now I don't know of a wallet that has a sensible UI/workflow for multi-transaction signing sessions. #1104 (comment)

@steveluscher steveluscher self-requested a review December 10, 2025 02:04
Copy link
Collaborator

Talked to @mcintyre94 about this. I didn't know that some apps were already using the API in this way. I'll review this today.

Copy link
Collaborator

OK, maybe today.

@steveluscher
Copy link
Collaborator

OK, maybe today, but no guarantees.

`View transactions: https://explorer.solana.com/tx/${firstSignature}?cluster=devnet and https://explorer.solana.com/tx/${secondSignature}?cluster=devnet`,
);
} catch (e) {
console.error('Failed to send transactions', e);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note for future readers: this is a lie. The underlying API does not let you know which transaction failed to send; some of them might, in fact, have landed.

throw new WalletStandardError(WALLET_STANDARD_ERROR__FEATURES__WALLET_ACCOUNT_CHAIN_UNSUPPORTED, {
address: uiWalletAccount.address,
chain,
featureName: SolanaSignAndSendTransaction,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh dear. Nice find!

This needs to be a separate PR with an associated pnpm changeset note.

Comment on lines +145 to +147
if (inputs.length === 0) {
return [];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

These need to be in a separate PR with its associated ‘does not call the wallet's underlying ... implementation’ test.

Copy link
Collaborator

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

Thanks for this work, and sorry it's taken me so long.

I'm really struggling with this API. I understand the need for it now, but I think we should end up with one API and deprecate the old one. I think this looks like:

  • Mark the singular versions with @deprecated Use {plural version}
  • Export the plural versions
  • Rewrite all of the tests and examples to use the plural versions instead
  • Release 5.{y+1}.0
  • Delete the singular implementation
  • Release 6.0.0

Would you be OK with this @mcintyre94?

@mcintyre94
Copy link
Member

I can see the argument for just exporting the plural version, since it covers both use cases and mirrors the wallet-standard feature. It also mirrors the signers APIs which are all multi-transaction.

That said, I think the single transaction use case is going to be used overwhelmingly more common, and it is easier if you don't need to use a plural API and unpack the result from an array. The cost of providing the single API is very small, since it's just a wrapper around the plural one in the current implementation.

Most importantly though, given the limitations with error handling for multiple transactions, there is a semantic difference (in practice) between sending one transaction and sending multiple. If you're dealing with one then you can understand its success/error status, if you send multiple then an error means some might have landed. Apps that do send multiple will need to treat these cases as meaningfully different. So I think it might be worth keeping the single transaction versions, with their more predictable behaviour, for the typical case of an app sending only one transaction. And then we have a clear place to document the issues with multiple transactions on the plural API.

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.

Export plural versions of useSignTransaction and useSignAndSendTransaction

3 participants