@btx-tools SDK — BTX service-challenge admission control
    Preparing search index...

    Solve a BTX service challenge to produce a (nonce, digest, proof) tuple that btxd will accept on redemption.

    Modes:

    • 'rpc': delegate to btxd's solvematmulservicechallenge RPC. Pass an authenticated BtxChallengeClient in opts.rpcClient. Production note: the solve RPC shares the matmul backend with block-template mining; consumers MUST point at a dedicated non-mining btxd, otherwise individual solves can queue behind mining work for 10+ minutes.
    • 'wasm': solve locally with the optional @btx-tools/matmul-wasm kernel — byte-identical proof to 'pure-js', ~24× faster. Throws a clear error if the package isn't installed. No node required.
    • 'pure-js': solve locally with the ported TypeScript MatMul. Browser- compatible, no optional package. Slower than 'rpc'/'wasm'.
    • 'auto': prefers 'rpc' if a client is provided, else 'wasm' if the kernel is installed, else 'pure-js'.
    import { BtxChallengeClient, Solver } from '@btx-tools/challenges-sdk';

    const client = new BtxChallengeClient({
    rpcUrl: 'http://127.0.0.1:19332',
    rpcAuth: { user: 'rpcuser', pass: 'rpcpass' },
    });

    const challenge = await client.issue({
    purpose: 'ai_inference_gate',
    resource: 'model:gpt-x|route:/v1/generate',
    subject: 'tenant:abc123',
    });

    const proof = await Solver.solve(challenge, { mode: 'rpc', rpcClient: client });
    const result = await client.redeem(challenge, proof.nonce64_hex, proof.digest_hex);

    if (result.valid && result.reason === 'ok') {
    // Admit the caller.
    }
    import { Solver } from '@btx-tools/challenges-sdk';

    // Solve a challenge with no server-side help. Slow at default difficulty;
    // for production browser use cases, calibrate via `target_solve_time_s`.
    const proof = await Solver.solve(challenge, {
    mode: 'pure-js',
    pureJs: { maxTries: 100_000 },
    });
    import { Solver } from '@btx-tools/challenges-sdk';

    // ~24× the pure-JS kernel; byte-identical proof. Great for server/edge
    // solving without a btxd. (`'auto'` uses it automatically when installed.)
    const proof = await Solver.solve(challenge, {
    mode: 'wasm',
    wasm: { maxTries: 1_000_000 },
    });
    Index

    Constructors

    Methods

    Constructors

    Methods