Fix the four things that break a stranger's first ten minutes - #3
Merged
Conversation
A cold pass against the published product — docs.tx402.io, npm, PyPI — found the
guardrails trustworthy and the front door not. Four issues, none in the SDK.
The quickstart's merchant step could not work on a fresh clone. It cloned the
repo and ran the test merchant, calling it "a single command"; it fails with
`Cannot find package '@x402/core'`. The obvious repair makes it worse: `npm
install` exits 0, prints that it added packages, and installs none of them,
because this repository's workspace layout lives in `pnpm-workspace.yaml`, which
npm does not read, and `package.json` carries no `workspaces` field. The success
message is the trap. `pnpm install` is now an explicit step, with a caution
naming npm's silent no-op, a `corepack enable` hint, and the reassurance that
this applies only to running this repo's merchant — installing `tx402` into your
own project is an ordinary package install and works with any client.
The quickstart promised a key format both SDKs reject. It offered the
`solana-keygen` JSON array "or its base58 form"; neither language accepts base58,
and both say so. Wallets such as Phantom export base58, so a reader following the
page hits a wall holding a perfectly valid key. The claim is gone, replaced by a
pointer to `tools/b58-keypair.js` — the dependency-free converter that already
existed for this exact mismatch, and which reads the key from the environment
rather than argv so it never lands in shell history. Verified end to end with a
real ed25519 keypair.
Both TypeScript examples failed with the exact commands their README gave. They
import the workspace `tx402`, which resolves through a compiled `dist/` a clone
does not contain, so they die on `ERR_MODULE_NOT_FOUND` without a prior `pnpm
build`. That step is now present with its reason, including why the Python
examples need no equivalent: they import the source directly.
The documented Worker gateway could not boot — `No such module "node:crypto"` —
and `nodejs_compat` appeared nowhere in the docs. `tx402/gateway/worker` reaches
`core/ledger`, which imports `node:crypto`. Both `wrangler.jsonc` examples now
carry `compatibility_flags: ["nodejs_compat"]` plus the `name`, `main` and
`compatibility_date` they were missing, so the block is one you can copy and
deploy. A table records which entry point needs the flag, traced through the
published bundle:
tx402 yes
tx402/durable-object yes (durableObjectSpendStore reaches core/ledger)
tx402/gateway/worker yes
tx402/gateway no (the Node server reaches no Node built-in)
That distinction is easy to get wrong: the Durable Object *class* deliberately
avoids `node:crypto`, but importing the module that exports it does not, so a
Worker deploying the DO needs the flag too.
Verified against a real Workers runtime using the published 0.2.0 package:
without the flag wrangler warns on `node:crypto`; with it the Worker boots and
serves, answering a data token with `200 {"result":{"atomicGlobalFreeze":false}}`
and a bad token with `401`.
Documentation only — no package, source or behaviour changes, so there is nothing
to re-release. docs.tx402.io is already updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A cold pass against the published product — docs.tx402.io, npm, PyPI — found the guardrails trustworthy and the front door not. Four issues, none in the SDK. All four are reproduced below and their fixes verified rather than reasoned about.
The quickstart's merchant step could not work on a fresh clone
Step 2 cloned the repo and ran the test merchant, calling it "a single command". It fails:
The obvious repair makes it worse.
npm installexits 0 and printsadded 151 packages— and installs none of the workspace's dependencies, because the workspace layout lives inpnpm-workspace.yaml, which npm does not read, andpackage.jsoncarries noworkspacesfield. The success message is the trap.pnpm installis now an explicit step, with a caution naming npm's silent no-op, acorepack enablehint, and the reassurance that this applies only to running this repo's merchant — installingtx402into your own project is an ordinary package install that works with any client.The quickstart promised a key format both SDKs reject
Step 3 offered the
solana-keygenJSON array "or its base58 form". Neither language accepts base58:Wallets such as Phantom export base58, so a reader following the page hits a wall while holding a perfectly valid key. The claim is removed and replaced with a pointer to
tools/b58-keypair.js— the dependency-free converter that already existed for this exact mismatch, and which takes the key from the environment rather thanargvso it never reaches shell history orps. Verified end to end with a real ed25519 keypair: base58 in, JSON array out, accepted by both SDKs.Both TypeScript examples failed with the exact commands their README gave
They import the workspace
tx402, which resolves through a compileddist/that a clone does not contain, so both die onERR_MODULE_NOT_FOUNDwithout a priorpnpm build. That step is now in the README with its reason — and with why the three Python examples need no equivalent: they import the source directly.The documented Worker gateway could not boot
and
nodejs_compatappeared zero times in the published docs.tx402/gateway/workerreachescore/ledger, which importsnode:crypto.Both
wrangler.jsoncexamples now carrycompatibility_flags: ["nodejs_compat"], plus thename,mainandcompatibility_datethey were missing — so the block is one a reader can copy and deploy. A table records which entry point needs the flag, traced through the published bundle rather than assumed:nodejs_compattx402tx402/durable-objectdurableObjectSpendStorereachescore/ledgertx402/gateway/workertx402/gatewayThat distinction is easy to get wrong, and the docs previously invited the wrong answer: the Durable Object class deliberately avoids
node:crypto, but importing the module that exports it does not, so a Worker deploying the DO needs the flag too.Verified against a real Workers runtime with the published
tx402@0.2.0:"node:crypto" wasn't found … enable the "nodejs_compat" flag/v1/capabilities200 {"result":{"atomicGlobalFreeze":false}}401Scope
Documentation only. No package, source or behaviour changes, so there is nothing to re-release. docs.tx402.io already serves these fixes.