Context
An audit of JS SDK content across the docs found snippets that fail if copied as written. Each item below is a concrete fix with an exact location. These are copy-paste bugs, not API staleness; the surrounding pages are otherwise current.
Checklist
docs/data/apis/horizon/api-reference/errors/error-handling.mdx
docs/learn/fundamentals/contract-development/contract-interactions/stellar-transaction.mdx
docs/learn/fundamentals/contract-development/contract-interactions/transaction-simulation.mdx
docs/tokens/how-to-issue-an-asset.mdx
docs/build/guides/transactions/path-payments.mdx
docs/data/apis/rpc/api-reference/methods/getLedgerEntries.mdx
Secondary (undefined variables, verify while in the file)
Acceptance criteria
- Every JS/TS snippet touched parses (paste into a TS playground or run
npx tsc --noEmit on extracted snippets).
- No JS block contains non-JS code.
Demo copy of stellar#2562 (original author: oceans404) — seeded for the triage-agent demo; content unchanged apart from neutralized mentions.
Context
An audit of JS SDK content across the docs found snippets that fail if copied as written. Each item below is a concrete fix with an exact location. These are copy-paste bugs, not API staleness; the surrounding pages are otherwise current.
Checklist
docs/data/apis/horizon/api-reference/errors/error-handling.mdxlet server = sdk.Server("https://horizon-testnet.stellar.org");uses the pre-v10 constructor withoutnewand without theHorizonnamespace. Change tolet server = new sdk.Horizon.Server("https://horizon-testnet.stellar.org");time.sleep(5 * time.Second);is Go code inside a JS block. Replace withawait new Promise((resolve) => setTimeout(resolve, 5000));let server = Horizon.Server(...)is missingnew. Also normalize the inconsistentsdk.vsStellarSdk.naming across the page's snippets.docs/learn/fundamentals/contract-development/contract-interactions/stellar-transaction.mdxrpc as StellarRpcappears inside a CommonJSrequire()destructure.asaliasing is import-statement syntax; in a destructure it must berpc: StellarRpc(or convert the block to an ESM import).docs/learn/fundamentals/contract-development/contract-interactions/transaction-simulation.mdxconst s = Server("https://soroban-testnet.stellar.org");is missingnew.BASE_FEE,nativeToScVal, andAddresswithout importing them. Add them to the import statements.docs/tokens/how-to-issue-an-asset.mdx‘...’), which is a syntax error if copied. Replace with straight quotes.StellarSdkwith no import shown; add theimport * as StellarSdk from "stellar/stellar-sdk";line (the full sample at the bottom already has it).docs/build/guides/transactions/path-payments.mdxawait SERVER.submitTransaction(transaction)references an undefinedSERVER. Use the Horizon server variable defined earlier in the snippet.docs/data/apis/rpc/api-reference/methods/getLedgerEntries.mdxconst s = new Server(...)with no import shown and no namespace. Showimport { Server } from "stellar/stellar-sdk/rpc";(and theAssetTypeimport used nearby).Secondary (undefined variables, verify while in the file)
docs/build/guides/basics/automate-reset-data.mdxline 180:networkPassPhraseis never defined (casing mismatch); line 264:returnContractResponseis never defined. The script also usesAssetandnativeToScValwithout importing them.docs/build/guides/transactions/submit-transaction-wait-js.mdxline 36:throw tmpStatus;references an undefined variable. Note this page defines the sharedsubmitTxhelper reused by several other guides, so fix carefully.docs/build/guides/archival/restore-contract-js.mdxline 69:function getWasmLedgerKey(entry: xdr.ContractDataEntry): {has an empty return type annotation (syntax error), and the file usesxdr.*without importingxdr.Acceptance criteria
npx tsc --noEmiton extracted snippets).Demo copy of stellar#2562 (original author: oceans404) — seeded for the triage-agent demo; content unchanged apart from neutralized mentions.