Signing Transactions

After the user authenticates, the Enoki SDK can return a key pair for the user. You can use this key pair to sign the user's transactions.


Consider the following code example. Unseen here, both the SuiClientProvider and EnokiFlowProvider contexts wrap the root of this app. Doing this provides access to the useSuiClient and useEnokiFlow hooks.

When the user taps or clicks the Sign transaction button, this example has Enoki retrieve the key pair created during a separate log in workflow (enokiFlow.getKeypair()). The logic then uses that result to sign the transaction built to the txb variable.

import { Transaction } from '@mysten/sui/transactions';
import { useSuiClient } from '@mysten/dapp-kit';
import { useEnokiFlow } from '@mysten/enoki/react';
function Demo() {
	const client = useSuiClient();
	const enokiFlow = useEnokiFlow();
	async function handleButtonClick() {
		// Get the keypair for the current user.
		const keypair = await enokiFlow.getKeypair();
		const txb = new Transaction();
		// Add some transactions to the block...
		// Sign and execute the transaction, using the Enoki keypair
		await client.signAndExecuteTransactionBlock({
			signer: keypair,
			transactionBlock: txb,
	return <button onClick={handleButtonClick}>Sign transaction</button>;

Unlike a wallet, this example does not require confirmation to approve the transaction. In a production app, you should provide logic that informs the user they are performing a transaction and allow them to cancel it if it was unintended.

On this page