SyscoinJS for UTXO applications
SyscoinJS connects JavaScript applications to Syscoin’s UTXO chain. It can look up transactions and available outputs through Blockbook, select inputs, and build a partially signed Bitcoin transaction (PSBT) for a wallet to approve. Pali v5 uses syscoinjs-lib@2.0.0 to retrieve previous transactions and interpret PSBT inputs and outputs. The examples below use the same version. Pali’s package pin · Pali’s transaction lookup · Pali’s PSBT handling · Published SDK
Install in a Node.js project
The examples run with Node.js 22. In a new directory, initialize the project before installing the SDK.
mkdir syscoinjs-quickstart
cd syscoinjs-quickstart
npm init -y
npm install --save-exact syscoinjs-lib@2.0.0
Read a transaction on mainnet
Run this in the project directory. The SDK takes the Blockbook base URL and adds the API path itself. This example reads the coinbase transaction in Syscoin block 2,345,720. It prints the containing block’s height and hash. The current index height changes as new blocks arrive.
node <<'JS'
const { utils } = require('syscoinjs-lib');
async function main() {
const blockbook = 'https://blockbook.syscoin.org';
const txid = 'f86cd23a46b743acff73119dd1e5df02661a19dbac43c0bca75460de410468d3';
const info = await utils.fetchProviderInfo(blockbook);
if (info?.blockbook?.coin !== 'Syscoin' || info?.backend?.chain !== 'main') {
throw new Error('Expected a Syscoin mainnet indexer');
}
const tx = await utils.fetchBackendRawTx(blockbook, txid);
if (tx?.txid !== txid) throw new Error('Transaction lookup failed');
console.log({
indexHeight: info.blockbook.bestHeight,
txid: tx.txid,
blockHeight: tx.blockHeight,
blockHash: tx.blockHash
});
}
main().catch(error => { console.error(error.message); process.exitCode = 1; });
JS
The transaction’s blockHash is 6c5dc51f2e929822702fcac8281081f05088972c1ddd6eaeb11e0d20014079ac. You can open the same record directly over HTTPS or query your own Core node for the block and its ChainLock. Blockbook transaction · Core commands
Build an unsigned Tanenbaum payment
This offline example spends a fictional 100,000-satoshi output, pays 40,000 satoshis to a testnet address, and returns the change. The builder has no signer or backend. It returns the unsigned PSBT for inspection. One SYS is 100,000,000 satoshis. SDK output amounts are utils.BN values in satoshis and the fee rate is in satoshis per virtual byte. SDK builder and return values · Syscoin address networks
node <<'JS'
const { syscoin: Syscoin, utils } = require('syscoinjs-lib');
async function main() {
const builder = new Syscoin(null, null, utils.syscoinNetworks.testnet);
const change = 'tsys1qzyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3g9m666';
const recipient = 'tsys1qyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3z8c7ujd';
const utxos = [{
txid: 'ab'.repeat(32), vout: 0, value: '100000',
address: change, confirmations: 6
}];
const outputs = [{ address: recipient, value: new utils.BN(40000) }];
const feeRate = new utils.BN(2);
const { psbt, fee } = await builder.createTransaction(
{ rbf: true }, change, outputs, feeRate, undefined, utxos
);
console.log({
inputs: psbt.inputCount,
outputs: psbt.txOutputs.map(out => ({ address: out.address, sats: out.value.toString() })),
feeSats: fee.toString(),
unsignedPsbt: psbt.toBase64()
});
}
main().catch(error => { console.error(error.message); process.exitCode = 1; });
JS
With this fixture and SDK version, the PSBT contains one input, the 40,000-satoshi payment, 59,706 satoshis of change, and a 294-satoshi fee. In a wallet integration, the inputs come from the user’s actual outputs, change goes to their wallet, and the wallet authorizes the payment. Supplying a signer to createTransaction enables the SDK’s signing and submission path when no funding address or xpub is passed. Use the signer-free builder above when your application hands the PSBT to a wallet for approval. Signing and submission behavior
Hand a payment to Pali in a browser
A connected dApp can let the user review and sign a PSBT built from their actual wallet inputs. Build for the network selected in Pali’s UTXO mode. On the user’s approval action, pass the SDK’s JSON wrapper to sys_sign. The wrapper contains the Base64 PSBT and its serialized asset map. For an ordinary SYS payment the map is empty. sys_sign requests a signature in Pali. Broadcasting is a separate action. SDK serialization · Pali signing method · Pali’s approval payload
import { utils } from 'syscoinjs-lib';
export async function requestPaliSignature(psbt, assets = new Map()) {
if (!window.pali?.request) throw new Error('Pali provider unavailable');
await window.pali.request({ method: 'sys_requestAccounts', params: [] });
return window.pali.request({
method: 'sys_sign',
params: [utils.exportPsbtToJson(psbt, assets)]
});
}
Other SDK calls
| Task | Entry point |
|---|---|
| Look up available outputs for a public address | utils.fetchBackendUTXOS(blockbook, address). The indexer reports values in satoshis. UTXO lookup |
| Read an indexed block by hash | utils.fetchBackendBlock(blockbook, blockHash). Block lookup |
| Build a Syscoin Platform Token allocation transfer | builder.assetAllocationSend(...) takes an asset map keyed by GUID. Its outputs carry asset amounts and it uses SYS inputs for fees. Allocation builder · UTXO assets and Z-DAG |
For raw REST calls, use the Blockbook API reference. To call an EVM contract, use NEVM JSON-RPC or the zkSYS Genesis RPC.