Skip to content

Update dapp skill to JS SDK v16 (contract.Client, Node 22, pollTransaction)#43

Open
oceans404 wants to merge 3 commits into
stellar:mainfrom
oceans404:fix/dapp-skill-sdk-v16
Open

Update dapp skill to JS SDK v16 (contract.Client, Node 22, pollTransaction)#43
oceans404 wants to merge 3 commits into
stellar:mainfrom
oceans404:fix/dapp-skill-sdk-v16

Conversation

@oceans404

Copy link
Copy Markdown
Contributor

What

Re-grounds the SDK-mechanics sections of the dapp skill against the official JS SDK docs (v16), which now publish llms.txt / llms-full.txt bundles for AI tools. Several patterns in the skill had drifted from what the docs treat as canonical.

Changes

  • Node 22 requirement. Skill said Node 20+; SDK v16 requires Node 22 (engines: >=22.0.0). Added notes that @stellar/stellar-base is folded into @stellar/stellar-sdk, the SDK is ESM-first, and it uses native fetch.
  • Lead contract invocation with contract.Client. The docs' canonical "Invoke a Contract" guide uses Client.from<T>()method()signAndSend(), and calls AssembledTransaction the "main workhorse." The skill only showed the low-level Contract.call + assembleTransaction path. Now the typed client is primary; the low-level path is kept as an advanced note (using prepareTransaction).
  • Bounded polling. Replaced the hand-rolled unbounded while (status === "NOT_FOUND") loop with rpc.pollTransaction.
  • One-line contract reads. Added rpc.queryContract / rpc.getContractMethods; kept manual getLedgerEntries as an advanced fallback.
  • Typed errors. Balance example now branches on NotFoundError instead of error.response?.status === 404, and points to Horizon result codes for submission failures.
  • Sourcing note. Documents that SDK mechanics track the JS SDK docs, while wallet (Freighter, Stellar Wallets Kit), passkey/smart-account, and OpenZeppelin relayer sections are separate packages and should be verified against their own upstream docs (not done in this PR).

Why

Skills are consumed by AI agents that copy examples verbatim. The old contract-invocation and polling patterns still compile but are lower-level than the docs recommend, and the Node version was factually wrong.

Notes for reviewers

oceans404 added 3 commits July 6, 2026 12:13
….Client

Re-grounds the SDK-mechanics sections against the official JS SDK docs
(stellar.github.io/js-stellar-sdk):

- Node 20+ -> Node 22+; note stellar-base folded into stellar-sdk, ESM-first,
  native fetch (v16 migration).
- Lead smart contract invocation with the typed contract.Client
  (Client.from<T> -> method() -> signAndSend); demote the low-level
  Contract.call path to an advanced note using prepareTransaction.
- Replace the unbounded getTransaction poll loop with rpc.pollTransaction.
- Add rpc.queryContract / getContractMethods one-liners for reading contract
  state; keep manual getLedgerEntries as advanced.
- Use the typed NotFoundError in the balance example and point to result codes
  for submission failures.
- Add a sourcing note: SDK mechanics track the JS SDK docs; wallet, passkey,
  and relayer sections are separate packages verified against their own docs.
Copilot AI review requested due to automatic review settings July 6, 2026 19:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the skill documentation set (primarily the dapp skill) to align Soroban/JS client patterns with @stellar/stellar-sdk v16 guidance, while also incorporating stacked documentation hygiene fixes (e.g., deduping standards references and correcting copy/paste snippet issues).

Changes:

  • Refreshes dapp SDK mechanics to v16 patterns: Node 22 requirement notes, contract.Client-first invocation, prepareTransaction for low-level paths, and rpc.pollTransaction for bounded polling.
  • Fixes/modernizes copy-paste examples across skills (e.g., lazy per-network config factories, missing imports in Rust examples).
  • Deduplicates/condenses large reference sections in standards to point to canonical guides.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
skills/standards/SKILL.md Replaces long inlined security/tools/ecosystem catalogs with pointers and compact link lists to reduce drift.
skills/smart-contracts/testing.md Adds missing IntoVal import so the auth-mocking example compiles when copied.
skills/smart-contracts/development.md Adds missing symbol_short / vec imports so the data-types example compiles when copied.
skills/data/SKILL.md Makes network config resolution lazy and adds an explicit unknown-network guard.
skills/dapp/SKILL.md Updates SDK v16 guidance and examples (Node 22+, contract.Client, bounded polling, typed error note, read helpers).
skills/assets/SKILL.md Replaces placeholder SEP snippets with accurate prose summaries + spec links.
skills/agentic-payments/SKILL.md Minor wording update in troubleshooting guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread skills/dapp/SKILL.md
Comment on lines +95 to +99
horizonUrl: "https://horizon-testnet.stellar.org",
rpcUrl: "https://soroban-testnet.stellar.org",
networkPassphrase: StellarSdk.Networks.TESTNET,
friendbotUrl: "https://friendbot.stellar.org" as string | null,
};
Comment thread skills/dapp/SKILL.md
The canonical way to call a Soroban contract from JS is the `contract.Client`, not hand-built `Contract.call` + `assembleTransaction`. The client reads the contract's interface from the network, so each method is callable by name and returns an `AssembledTransaction`. You get a native JS result and don't build ScVals by hand.

```typescript
import { contract, rpc, Networks } from "@stellar/stellar-sdk";
Comment thread skills/dapp/SKILL.md
Comment on lines +297 to +309
export async function getCounterClient(
contractId: string,
publicKey: string,
signTransaction: contract.ClientOptions["signTransaction"],
) {
return contract.Client.from<CounterContract>({
contractId,
rpcUrl: "https://soroban-testnet.stellar.org",
networkPassphrase: Networks.TESTNET,
publicKey,
signTransaction,
});
}
Comment thread skills/dapp/SKILL.md
Comment on lines +340 to 343
const transaction = new StellarSdk.TransactionBuilder(account, {
fee: StellarSdk.BASE_FEE,
networkPassphrase: config.networkPassphrase,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants