solana-tx-serialize
v1.0.4
Published
Package for serializing Solana transactions
Downloads
1
Readme
solana-tx-serialize
Serialize Solana web3.Transaction objects to bs58 and back
Install
yarn add solana-tx-serialize
npm install solana-tx-serialize
Example
const pk = Keypair.generate();
const inst = SystemProgram.createAccount({
fromPubkey: pk.publicKey,
newAccountPubkey: pk.publicKey,
lamports: 0,
space: 0,
programId: SystemProgram.programId,
});
const tx = new Transaction();
tx.add(inst);
tx.recentBlockhash = Keypair.generate().publicKey.toBase58();
tx.feePayer = pk.publicKey;
tx.sign(pk);
const bs58string = bs58Transaction(tx);
console.log(bs58string);
const decodedTx = unbs58Transaction(bs58string);
console.log(decodedTx);