diff --git a/network/soroban-rpc/api-reference/methods/getTransaction.mdx b/network/soroban-rpc/api-reference/methods/getTransaction.mdx index 8ab2b45c8..2077099f4 100644 --- a/network/soroban-rpc/api-reference/methods/getTransaction.mdx +++ b/network/soroban-rpc/api-reference/methods/getTransaction.mdx @@ -2,7 +2,76 @@ hide_title: true description: Returns transaction details --- - +import { CodeExample } from "@site/src/components/CodeExample"; import { RpcMethod } from "@site/src/components/RpcMethod"; + +### SDK Guide + +The example above is querying details of a transaction using RPC methods directly. If you are using the Stellar SDK to build applications, you can use the native functions to get the same information. + + + +```python +# pip install --upgrade stellar-sdk +from stellar_sdk import SorobanServer, soroban_rpc + + +def get_transaction(hash: str) -> soroban_rpc.GetTransactionResponse: + server = SorobanServer(server_url='https://soroban-testnet.stellar.org', client=None) + tx = server.get_transaction(hash) + return tx + +tx = get_transaction("6bc97bddc21811c626839baf4ab574f4f9f7ddbebb44d286ae504396d4e752da") + +print("result", tx.status) +``` + +```js +// yarn add @stellar/stellar-sdk +import { Server } from "@stellar/stellar-sdk/rpc"; + +const server = new Server("https://soroban-testnet.stellar.org"); + +// Fetch transaction details +async function getTransactionDetails(hash) { + try { + server.getTransaction(hash).then((tx) => { + console.log({"result": tx}); + }); + } catch (error) { + console.error("Error fetching transaction:", error); + } +} + +getTransactionDetails("6bc97bddc21811c626839baf4ab574f4f9f7ddbebb44d286ae504396d4e752da"); +``` + +```go +// go get github.com/stellar/go/clients/horizonclient + +package main + +import ( + "fmt" + "net/http" + + "github.com/stellar/go/clients/horizonclient" +) + +func main() { + client := horizonclient.Client{ + HorizonURL: "https://horizon-testnet.stellar.org", + HTTP: http.DefaultClient, + } + res, err := client.TransactionDetail("84577409a21a25c60b610667c5a2e9355d65393af20cb96f8ac506d3991b9230") + if err != nil { + fmt.Println(err) + } + fmt.Println(res) +} +``` + + +