Skip to main content

Non Custodial Flow

LaserSell never touches your private key. Every transaction follows this pattern:
  1. Build: The API returns a base64 encoded unsigned VersionedTransaction.
  2. Sign: You decode, sign, and re encode locally using your keypair.
  3. Submit: You send the signed transaction to the Solana network via a send target.

Loading a Keypair

All SDKs expect a Solana keypair. The standard format is a JSON file containing an array of 64 bytes (as used by solana-keygen).
import { readFile } from "node:fs/promises";
import { Keypair } from "@solana/web3.js";

const raw = await readFile("./keypair.json", "utf8");
const keypair = Keypair.fromSecretKey(
  Uint8Array.from(JSON.parse(raw))
);

Signing Functions

Standard Sign

Decodes the unsigned transaction, signs it with your keypair, and returns a signed VersionedTransaction object.
import { signUnsignedTx } from "@lasersell/lasersell-sdk";

const signedTx = signUnsignedTx(unsignedTxB64, keypair);

Fast Sign (TypeScript)

The TypeScript SDK provides signUnsignedTxB64Fast, which signs the raw bytes in place without deserializing through VersionedTransaction. This avoids allocation on the hot path and returns the signed transaction as a base64 string directly.
import { signUnsignedTxB64Fast } from "@lasersell/lasersell-sdk";

const signedTxB64 = signUnsignedTxB64Fast(unsignedTxB64, keypair);

Sign and Send (One Step)

Combines signing and submission into a single call.
import { signAndSendUnsignedTxB64, sendTargetHeliusSender } from "@lasersell/lasersell-sdk";

const signature = await signAndSendUnsignedTxB64(
  sendTargetHeliusSender(),
  unsignedTxB64,
  keypair,
);

Submitting the Signed Transaction

After signing, submit to the Solana network using a send target:
import { sendTransaction, sendTargetHeliusSender } from "@lasersell/lasersell-sdk";

const signature = await sendTransaction(sendTargetHeliusSender(), signedTx);

Error Types

Signing and submission errors are surfaced through TxSubmitError:
KindDescription
decode_unsigned_txBase64 decoding of the unsigned transaction failed.
deserialize_unsigned_txTransaction bytes could not be deserialized.
sign_txSigning failed (wrong keypair, corrupted data).
serialize_txSerialization of the signed transaction failed.
request_sendNetwork error during submission.
response_readCould not read the RPC response body.
http_statusNon 2xx HTTP response from the RPC endpoint.
decode_responseResponse body was not valid JSON.
rpc_errorRPC returned an error object.
missing_resultResponse did not contain a transaction signature.

Security Best Practices

  • Never log or transmit your private key.
  • Load keys from environment variables or encrypted files in production.
  • Verify the wallet address matches the user_pubkey used in the build request. The API constructs the transaction for that specific signer.