The Nexa ecosystem infrastructure is constantly being developed and improved, and this time it is our pleasure to present Libnexa-TS 3.1.0, a new release with read-only inputs. Libnexa-TS is an open-source library and provides a reliable SDK for TypeScript/JavaScript apps that need to interface with the Nexa network. It’s designed for developers and now supports read-only inputs, which allow multiple transactions to access the same data, and it is useful for UTXO smart contracts and token authorities.
Read-Only Inputs
Nexa transactions can contain inputs that are not spent when the transaction is processed. In Libnexa-ts 3.1.0, TransactionBuilder adds support for read-only inputs via readOnly: true in UTXOs passed to from().
Quick start (requires Node.js 22+):
‘’
npm install [email protected]
‘’
As the network requires, read-only inputs have amount 0 and sequence number 0 (the builder sets both automatically), and they do not fund the transaction. A transaction must still include at least one regular input, and a UTXO must be confirmed in a block before it can be used as a read-only input.
‘’
import { TransactionBuilder } from ‘libnexa-ts’;
const builder = new TransactionBuilder();
// As a read-only input
builder.from({ outpoint: ‘0000…’, satoshis: 1000, address: ‘nexa:nqtsq5g…’, readOnly: true });
‘’
These inputs are skipped by sign() and can be signed explicitly with signInput(). isFullySigned() now accepts read-only inputs with an empty scriptSig without requiring a signature. Input preserves the supplied input type during construction and serialization round trips.
Use Cases
Read-only inputs are useful for bringing in transaction data from inputs that do not belong to the user creating the transaction, because they do not need to be signed. Data from these inputs can be accessed via transaction introspection and is useful for covenants and templates that want to consistently pull in data from a specific UTXO to be used in the transaction. Read-only inputs allow multiple transactions to access this data in parallel because the UTXO is not destroyed and recreated.
A nonzero-length signature on a read-only input can be used to prove ownership of a UTXO without spending it. This makes certain asset operations easier, specifically where owners are asked to prove ownership of an asset. Dividend and token reward distributions are classic examples of this use case. Contracts that rely on this must use introspection to check that the read-only input’s scriptSig is not empty.
The powers provided by a token authority UTXO can be reused by importing the authority UTXO as read-only and signing it, provided that the authority has the BATON flag set. This makes token operations more efficient and easier to develop, since the “import and rewrite” design pattern is no longer needed.
To Wrap Up
The decentralized nature of the Nexa network allows for highly resilient Nexa infrastructure, and the developer community needs reliable, open-source tools to implement Nexa apps and services. Libnexa-ts provides a reliable SDK for TypeScript and JavaScript developers.
Documentation: nexa.gitlab.io/libnexa-ts
Release notes: gitlab.com/nexa/libnexa-ts/-/releases/v3.1.0
Read-only inputs specification: spec.nexa.org/script/read-only-inputs
