Skip to main content

Sign Transaction

Associated methods or objects for interacting with the Solana blockchain.


For more information about the nature of transactions on Solana, it is recommended to review the `@solana/web3.js` docs as well as the official Solana docs.

signTransaction

Method for signing a transaction. This method will sign and return the transaction back to the application.

Examples

    const network = "<NETWORK_URL>";
const connection = new Connection(network);
const blockhash = (await connnection.getRecentBlockhash("finalized")).blockhash;
const instruction = SystemProgram.transfer({
fromPubkey: new PublicKey(publicKeys[0]),
toPubkey: new PublicKey(publicKeys[1]),
lamports: 0.1 * LAMPORTS_PER_SOL
});

const transaction = new Transaction({
recentBlockhash: blockhash,
feePayer: new PublicKey(publicKeys[0])
}).add(TransactionInstruction);const transaction2 = new Transaction();

const signedTransaction = await torus.signTransaction(transaction);
const signature = await connection.sendRawTransaction(signedTransaction.serialize());

Reference

    signAllTransactions(transactions: Transaction[]): Promise<Transaction[]>;

signAllTransaction

Method for signing multiple transaction

Examples

    const network = "<NETWORK_URL>";
const connection = new Connection(network);

const blockhash = (await connnection.getRecentBlockhash("finalized")).blockhash;
const instruction = SystemProgram.transfer({
fromPubkey: new PublicKey(publicKeys[0]),
toPubkey: new PublicKey(publicKeys[1]),
lamports: 0.1 * LAMPORTS_PER_SOL
});
const transaction = new Transaction({
recentBlockhash: blockhash,
feePayer: new PublicKey(publicKeys[0])
}).add(TransactionInstruction);
const transaction2 = new Transaction({
recentBlockhash: blockhash,
feePayer: new PublicKey(publicKeys[3])
}).add(TransactionInstruction);

const signedTransaction = await torus.signAllTransaction([transaction, transaction2]);
const signature = await connection.sendRawTransaction(signedTransaction.serialize());

Reference

    signTransaction(transaction: Transaction): Promise<Transaction>;