SDK

Install

The SDK is the voynich package: TypeScript, for the browser and for Node 22 or later. It is an ES module.

Shell
npm install voynich

It brings @voynich/contract, the typed client of the HTTP API and the types of everything the API returns.

In Node#

The default export is a client configured from the environment on first use.

TypeScript
import voynich from 'voynich'

const { output, receipt, verified } = await voynich.call('sketch-32', pixels)
VariableMeaning
VOYNICH_API_URLThe address of the Voynich API, https://<api host>. Without it the client looks for an API on http://127.0.0.1:9702.
VOYNICH_KEYPAIRThe path of a Solana JSON keypair file: the wallet that signs and pays. Read by call, seal, grant, revoke, setPrice, retire and refund, and by account when no wallet is passed. verify, models, model, enclaves, enclave and account(wallet) do not read it.

The default export has call, verify, seal, models, model, enclaves, enclave, grant, revoke, setPrice, retire, refund and account. api and send are on a client made with createVoynich.

In the browser#

Create a client with the API's address and the connected wallet.

TypeScript
import { createVoynich } from 'voynich'

const voynich = createVoynich({ apiUrl: 'https://<api host>', signer: wallet })

createVoynich works the same way in Node, with a Keypair as the signer.

Options#

FieldMeaning
apiUrlstringrequired

The address of the Voynich API.

signerWalletSigner | Keypair

What signs transactions. A WalletSigner is any object with a publicKey (a web3.js PublicKey) and signTransaction(transaction: VersionedTransaction) that resolves to the signed transaction, which is what wallet adapters provide. A web3.js Keypair signs directly. Without a signer the client reads and verifies, and a write throws WALLET_REQUIRED.

connectionConnection

The web3.js Connection the client reads chain accounts through when it checks an enclave or a receipt. Without it the client connects to the rpcUrl in GET /v1/config at confirmed commitment. Verification trusts this view of the chain, so pass a connection to an RPC of your own to verify independently of the API.

headersRecord<string, string>

Headers added to every API request.

fetchtypeof fetch

The fetch to use. The global one by default.

pollMsnumber

How often the client polls while it follows a transaction or waits for an answer, in milliseconds. 500 by default.

fixturestring

A scenario name for an API running in fixture mode, used when building an interface without a cluster.

The client#

MemberDoesReference
call(model, input, options?)Calls a sealed model and returns the verified answer.call
verify(id, options?)Checks a receipt against the chain.verify
seal(options)Encrypts a model, writes it to chain and seals it.seal
grant(model, enclave, modelKey)Grants a model to an enclave as its owner.grant and refund
revoke(model, enclave)Revokes an enclave's grant as the owner.grant and refund
setPrice(model, price, operatorShareBps)Sets the price and the operator share as the owner.grant and refund
retire(model)Retires a model as the owner.grant and refund
refund(call)Takes back the escrow of a call past its deadline.grant and refund
models, model, enclaves, enclave, accountRead models, enclaves and a wallet's side.Models and enclaves
apiThe typed client of every HTTP route.HTTP API
send(build)Signs a transaction the API built, submits it and follows it until it confirms.grant and refund

Entry points#

ImportHolds
voynichcreateVoynich, VoynichError, preprocessSketch, the cryptography functions and the default client. In Node the default client reads the environment.
voynich/nodeThe Node entry itself: everything in voynich, with the default client that reads the environment.
voynich/cryptoThe cryptography alone: sealing weights, wrapping keys, call envelopes, the receipt message and its verification. No dependency on Solana libraries.
voynich/programThe program's address, PDA derivation, typed Anchor program clients and the decoders of the attestation record and the Weights header.
voynich/idl/voynich, voynich/idl/attestThe IDLs as TypeScript modules.

Every export is listed in Types and errors.