@rango-dev/signer-solana
v0.35.0
Published
## Summary
Downloads
1,871
Readme
@rango-dev/signer-solana
Summary
Signer for Rango Solana Transactions
Currecntly all Rango Solana transactions are Versioned (and serialized), only Solana Wrapper is already using the legacy format. (which is used only for SOL <-> WSol routes)
Versioned Transaction Sign Flow Overview:
Get connection and recent blockhash
const connection = new Connection(SOLANA_RPC_URL, { commitment: 'confirmed', disableRetryOnRateLimit: false, }); const latestBlock = await connection.getLatestBlockhash('confirmed');
Prepare the transaction
const transaction = VersionedTransaction.deserialize( new Uint8Array(tx.serializedMessage) ); transaction.message.recentBlockhash = recentBlockhash;
Simulate the transaction
const { value } = await connection.simulateTransaction(transaction, { replaceRecentBlockhash: true, commitment: 'processed', });
Sign the transaction
const signedTransaction = await solanaProvider.signTransaction( solanaWeb3Transaction ); const serializedTransaction = Buffer.from(signedTransaction.serialize());
Send and confirm the transaction (similar to jupiter suggested code)
const { txId, txResponse } = await transactionSenderAndConfirmationWaiter({ connection, serializedTransaction, });