Actions
Sign Transaction
Sign a Sui transaction without executing it for deferred or multi-signature scenarios.
The signTransaction action prompts the connected wallet to sign a transaction without executing
it. This is useful when you need a signed transaction for later execution or for multi-signature
scenarios.
Usage
import { createDAppKit } from '@mysten/dapp-kit-core';
import { Transaction, coinWithBalance } from '@mysten/sui/transactions';
const dAppKit = createDAppKit({
/* config */
});
const tx = new Transaction();
// No need to manually set sender - it's done automatically
tx.transferObjects([coinWithBalance({ balance: 123 })], '0xrecipient...');
// Sign the transaction without executing it
const { bytes, signature } = await dAppKit.signTransaction({
transaction: tx,
});Parameters
transaction:Transaction | string- The transaction to sign. Can be either a Transaction instance or base64-encoded bcs bytes for the transaction.account(optional) -UiWalletAccount- The account to sign with. Defaults to the currently connected account. Must belong to the connected wallet, otherwise aWalletAccountNotFoundErroris thrown. Lets you sign with a specific account without changing the selected account viaswitchAccount.network(optional) - The network to sign against (a configured network identifier such as'mainnet'). Defaults to the active network. The chain and the client used to build the transaction are derived from it, so you can sign against a network without changing the active network viaswitchNetwork. Throws aChainNotSupportedErrorif the signing account does not support the network.signal(optional) -AbortSignal- An abort signal to cancel the signing request.
Return value
Returns a Promise that resolves to an object containing:
bytes:string- The signed transaction as a base64-encoded BCS stringsignature:string- The signature as a base64-encoded string
const result = await dAppKit.signTransaction({ transaction });
console.log('Signed transaction bytes:', result.bytes);
console.log('Signature:', result.signature);Transaction building
When passing a Transaction instance, the action automatically:
- Sets the sender address if not already set
- Builds the transaction using the current network's client
- Converts it to the appropriate format for the wallet
Wallet compatibility
- The action transparently handles both
sui:signTransactionandsui:signTransactionBlockwallet-standard features
// The action automatically detects and uses the appropriate method
// No special configuration needed
const result = await dAppKit.signTransaction({
transaction: tx,
});