npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@trezoa/transactions

v5.1.0

Published

Helpers for creating and serializing transactions

Readme

npm npm-downloads code-style-prettier

@trezoa/transactions

This package contains types and functions for compiling, signing and sending transactions. It can be used standalone, but it is also exported as part of Kit @trezoa/kit.

Transactions are created by compiling a transaction message. They must then be signed before being submitted to the network.

Compiling a transaction

Functions

compileTransaction()

Given a TransactionMessage, this function returns a Transaction object. This includes the compiled bytes of the transaction message, and a map of signatures. This map will have a key for each address that is required to sign the transaction. The transaction will not yet have signatures for any of these addresses.

Whether a transaction message is ready to be compiled or not is enforced for you at the type level. In order to be signable, a transaction message must:

  • have a version and a list of zero or more instructions (ie. conform to BaseTransactionMessage)
  • have a fee payer set (ie. conform to TransactionMessageWithFeePayer)
  • have a lifetime specified (ie. conform to TransactionMessageWithBlockhashLifetime | TransactionMessageWithDurableNonceLifetime)

Signing transactions

In order to be landed on the network, a transaction must be signed by all of the private keys belonging to accounts that are required signers of the transaction.

Types

FullySignedTransaction

This type represents a transaction that is signed by all of its required signers.

TransactionWithSizeLimit

This type represents a transaction that is under or equal to the maximum size limit for transactions on the Trezoa network.

SendableTransaction

This type represents a transaction that has all the required conditions to be sent to the network. Namely:

  • It must be fully signed (ie. conform to FullySignedTransaction)
  • It must be within size limit (ie. conform to TransactionWithSizeLimit)

The SendableTransaction type is a prerequisite of functions designed to land transactions on the network.

Functions

getSignatureFromTransaction()

Given a transaction signed by its fee payer, this method will return the Signature that uniquely identifies it. This string can be used to look up transactions at a later date, for example on a Trezoa block explorer.

import { getSignatureFromTransaction } from '@trezoa/transactions';

const signature = getSignatureFromTransaction(tx);
console.debug(`Inspect this transaction at https://explorer.trezoa.com/tx/${signature}`);

signTransaction()

Given an array of CryptoKey objects which are private keys pertaining to addresses that are required to sign a transaction, this method will return a new signed transaction of type FullySignedTransaction. This function will throw unless the resulting transaction is fully signed.

import { generateKeyPair } from '@trezoa/keys';
import { signTransaction } from '@trezoa/transactions';

const signedTransaction = await signTransaction([myPrivateKey], tx);

partiallySignTransaction()

This function is the same as signTransaction() but does not require the transaction to be signed by all signers. A partially signed transaction cannot be landed on the network, but can be serialized and deserialized.

Serializing transactions

Before sending a transaction to be landed on the network, you must serialize it in a particular way. You can use these types and functions to serialize a signed transaction into a binary format suitable for transit over the wire.

Types

Base64EncodedWireTransaction

This type represents the wire format of a transaction as a base64-encoded string.

Functions

getBase64EncodedWireTransaction()

Given a signed transaction, this method returns the transaction as a string that conforms to the Base64EncodedWireTransaction type.

import { getBase64EncodedWireTransaction, signTransaction } from '@trezoa/transactions';

const serializedTransaction = getBase64EncodedWireTransaction(signedTransaction);
const signature = await rpc.sendTransaction(serializedTransaction, { encoding: 'base64' }).send();