Solana: how to partially sign a Versioned Transaction

Solana: how to partially sign a Versioned Transaction
WEB3 ENGINEERING
Partually signed transaction are important part of some Solana scenarios. For example, to control something by the backend, or to generate some custom "beautiful" addresses.

The problem is: in the old, Legacy transactions, there was a method partialSign but in a modern VersionedTransaction this method is missing.

How to partially sign a VersionedTransaction?

const {ed25519} = require('@noble/curves/ed25519');

const sign = (
	message,
	secretKey
  ) => ed25519.sign(message, secretKey.slice(0, 32));

const transaction = new VersionedTransaction(message);
const extraSignature = sign(transaction.message.serialize(), mintKey.secretKey);
transaction.addSignature(mintKey.publicKey, extraSignature);

transaction.sign([wallet]);
Close
Ready to take your business to the next level? Let's talk
I agree to the Terms of Service
Made on
Tilda