Update asset issuance tutorial to use RPC instead of Horizon - #2833
Update asset issuance tutorial to use RPC instead of Horizon#2833kaankacar wants to merge 1 commit into
Conversation
The tutorial built and submitted every transaction through Horizon in JavaScript, Python, Java and Go. Point all four at Stellar RPC. Account loads become getAccount / load_account / LoadAccount. Submission becomes sendTransaction plus a poll, since RPC answers PENDING first. The Go source account is now a txnbuild.Account interface value, so the address-of operator is gone.
There was a problem hiding this comment.
Pull request overview
Updates the “How to issue an asset” tutorial to use Stellar RPC (account reads + transaction submission + polling) instead of Horizon across all four language examples, aligning the page with the docs’ current RPC-first guidance.
Changes:
- Adds an RPC-specific explanation (send →
PENDING→ poll viagetTransaction/pollTransaction). - Migrates JavaScript/Python/Java/Go snippets from Horizon account loading/submission to RPC equivalents (
getAccount/load_account/LoadAccount,sendTransaction+ polling). - Switches Go examples from
horizonclienttorpcclientand updates transaction-building to use the loaded account objects.
Recommendation: NEEDS-CHANGES — the newly added submission helpers treat any non-PENDING status as a hard failure, but RPC can return other non-error statuses (e.g. DUPLICATE, TRY_AGAIN_LATER) that shouldn’t be rejected; additionally one JS snippet uses top-level await with CommonJS require() which won’t run if copied verbatim.
Suppressed comments (4)
docs/tokens/how-to-issue-an-asset.mdx:597
send_transactioncan return non-PENDINGstatuses that are not submission failures (e.g.DUPLICATE,TRY_AGAIN_LATER). Failing on anything exceptPENDINGmakes the example reject valid responses; consider only raising onERRORand otherwise polling by hash.
send_response = server.send_transaction(transaction)
if send_response.status != SendTransactionStatus.PENDING:
raise RuntimeError(f"Submission failed: {send_response.status}")
docs/tokens/how-to-issue-an-asset.mdx:689
sendTransactioncan returnDUPLICATEorTRY_AGAIN_LATERin addition toPENDING; treating any non-PENDINGstatus as a submission failure can reject valid responses. Consider only throwing onERRORand otherwise polling by hash.
SendTransactionResponse trustSend = server.sendTransaction(allowAstroDollars);
if (trustSend.getStatus() != SendTransactionStatus.PENDING) {
throw new RuntimeException("Submission failed: " + trustSend.getStatus());
}
docs/tokens/how-to-issue-an-asset.mdx:706
sendTransactioncan returnDUPLICATEorTRY_AGAIN_LATERin addition toPENDING; treating any non-PENDINGstatus as a submission failure can reject valid responses. Consider only throwing onERRORand otherwise polling by hash.
SendTransactionResponse paymentSend = server.sendTransaction(sendAstroDollars);
if (paymentSend.getStatus() != SendTransactionStatus.PENDING) {
throw new RuntimeException("Submission failed: " + paymentSend.getStatus());
}
docs/tokens/how-to-issue-an-asset.mdx:739
SendTransactioncan return statuses other thanPENDING(e.g.DUPLICATE,TRY_AGAIN_LATER) that aren’t necessarily submission failures. Failing hard on any non-PENDINGstatus can cause the example to reject valid responses; consider only treatingERRORas a submission failure and otherwise polling by hash.
sendResp, err := client.SendTransaction(ctx, protocol.SendTransactionRequest{Transaction: txnB64})
if err != nil {
log.Fatal(err)
}
if sendResp.Status != "PENDING" {
log.Fatalf("Submission failed: %s", sendResp.Status)
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ```js | ||
| const StellarSdk = require("@stellar/stellar-sdk"); | ||
| const server = new StellarSdk.Horizon.Server( | ||
| "https://horizon-testnet.stellar.org", | ||
| ); | ||
| const account = await server.loadAccount(distributorKeypair.publicKey()); | ||
| const server = new StellarSdk.rpc.Server("https://soroban-testnet.stellar.org"); | ||
| const account = await server.getAccount(distributorKeypair.publicKey()); |
| var sendResponse = await server.sendTransaction(transaction); | ||
| if (sendResponse.status !== "PENDING") { | ||
| throw new Error("Submission failed: " + sendResponse.status); | ||
| } |
🤖 Automated triage bot, acting for @kaankacar.
Closes #1777
The asset issuance tutorial called Horizon in all four languages. This points every example at Stellar RPC. Account loads become
getAccount,load_account,LoadAccountandgetAccount. Submission becomessendTransactionplus a poll, because RPC answersPENDINGfirst. The page keeps its four languages, and no example needs an endpoint that RPC lacks.