wirebus
v0.2.0
Published
Wirebus SDK: drive any backend on Solana with signed commands (JSON or XML). Build, sign and send commands as transactions, no wallet connection.
Maintainers
Readme
wirebus
Drive any backend on Solana with signed JSON commands. No wallet connection.
Wirebus turns the Solana ledger into a programmable command bus: you put a small JSON command in a transaction memo and sign it. A Wirebus backend streams those transactions, validates them, proves the signer from the signature, and runs the matching handler. Every command is ordered, permanent and auditable.
This package is the client SDK: build, sign and send commands.
npm install wirebus @solana/web3.jsQuickstart (script / bot / agent)
Sign with your own Keypair and send. No connection, no session.
import { Connection, Keypair } from '@solana/web3.js';
import { sendCommand } from 'wirebus';
const connection = new Connection('https://api.devnet.solana.com', 'confirmed');
const signer = Keypair.fromSecretKey(/* your secret key */);
const signature = await sendCommand(connection, signer, {
controlAddress: 'CONTROL_ADDRESS_OF_THE_APP',
cmd: 'post',
args: { text: 'gm, on-chain' },
});
console.log('sent', signature);In the browser (any wallet, still no connect)
Build the transaction and hand it to a wallet to sign and send. The site never holds a session or your keys.
import { buildCommandTransaction } from 'wirebus';
const tx = buildCommandTransaction({
payer: wallet.publicKey,
controlAddress: 'CONTROL_ADDRESS_OF_THE_APP',
cmd: 'move',
args: { x: 1, y: 2 },
});
const sig = await wallet.sendTransaction(tx, connection);The command envelope (v1, frozen)
{
"v": 1, // protocol version, always 1
"cmd": "post", // command name, 1..64 chars
"args": { "text": "gm" }, // optional, validated per command
"nonce": "8f3ad9c1", // optional
"exp": 1719250000 // optional unix seconds, rejected if in the past
}import { encodeEnvelope, decodeEnvelope } from 'wirebus';
const memo = encodeEnvelope({ cmd: 'post', args: { text: 'gm' } });
const envelope = decodeEnvelope(memo); // -> { v: 1, cmd: 'post', args: { text: 'gm' } }API
sendCommand(connection, signer, input), build, sign with a Keypair, and send. Returns the signature.buildCommandTransaction(input), build an unsigned transaction to sign with any wallet.encodeEnvelope(input)/decodeEnvelope(memo)/isEnvelopeV1(x), the v1 envelope.buildMemoInstruction(memo), a raw Memo instruction.MEMO_PROGRAM_ID,ENVELOPE_VERSION,MAX_MEMO_BYTES,DEFAULT_REFERENCE_LAMPORTS.
@solana/web3.js is a peer dependency.
Notes
- A command transaction includes a Memo (the envelope) plus a small transfer to the app's control address so the relayer's subscription catches it.
- The signer of the transaction is the authenticated caller.
- Keep payloads small: the envelope is limited to 900 bytes.
Learn more at wirebus.io. MIT licensed.
