feat(docs): add xrpl-go GoLang package to XRPLF documentation site

This commit is contained in:
banasa44
2025-07-22 11:15:48 +02:00
committed by akcodez
parent ed22038bf7
commit 3ee23b8c7d
12 changed files with 382 additions and 104 deletions

View File

@@ -8,3 +8,4 @@ For more context, see the Get Started tutorial for your preferred language:
- [Java](https://xrpl.org/get-started-using-java.html)
- [JavaScript](https://xrpl.org/get-started-using-javascript.html)
- [PHP](https://xrpl.org/get-started-using-php.html)
- [GoLang](https://xrpl.org/get-started-using-golang.html)

View File

@@ -19,6 +19,7 @@ func main() {
client := rpc.NewClient(cfg)
// Get the latest validated ledger
led, err := client.GetLedger(&ledger.Request{
Transactions: true,
LedgerIndex: common.Validated,

View File

@@ -6,6 +6,7 @@ import (
"github.com/Peersyst/xrpl-go/xrpl/currency"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/queries/transactions"
"github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
"github.com/Peersyst/xrpl-go/xrpl/wallet"
@@ -13,108 +14,106 @@ import (
wstypes "github.com/Peersyst/xrpl-go/xrpl/websocket/types"
)
const (
WalletSeed = "sn3nxiW7v8KXzPzAqzyHXbSSKNuN9"
)
func main() {
client := websocket.NewClient(
websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233").
WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
)
defer client.Disconnect()
fmt.Println("⏳ Connecting to testnet...")
client := websocket.NewClient(
websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233").
WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
)
defer client.Disconnect()
if err := client.Connect(); err != nil {
fmt.Println(err)
return
}
if !client.IsConnected() {
fmt.Println("❌ Failed to connect to testnet")
return
}
fmt.Println("✅ Connected to testnet")
fmt.Println()
w, err := wallet.FromSeed(WalletSeed, "")
if err != nil {
fmt.Println(err)
return
}
fmt.Println("⏳ Funding wallet...")
if err := client.FundWallet(&w); err != nil {
fmt.Println(err)
return
}
fmt.Println("💸 Wallet funded")
fmt.Println()
xrpAmount, err := currency.XrpToDrops("1")
if err != nil {
fmt.Println(err)
return
}
xrpAmountInt, err := strconv.ParseInt(xrpAmount, 10, 64)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("⏳ Sending 1 XRP to rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe...")
p := &transaction.Payment{
BaseTx: transaction.BaseTx{
Account: types.Address(w.GetAddress()),
},
Destination: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
Amount: types.XRPCurrencyAmount(xrpAmountInt),
DeliverMax: types.XRPCurrencyAmount(xrpAmountInt),
}
flattenedTx := p.Flatten()
if err := client.Autofill(&flattenedTx); err != nil {
fmt.Println(err)
return
}
txBlob, _, err := w.Sign(flattenedTx)
if err != nil {
fmt.Println(err)
return
}
res, err := client.SubmitTxBlobAndWait(txBlob, false)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("✅ Payment submitted")
fmt.Printf("🌐 Hash: %s\n", res.Hash)
fmt.Printf("🌐 Validated: %t\n", res.Validated)
fmt.Println()
fmt.Println("⏳ Using SubmitTxAndWait with wallet")
fmt.Println()
flattenedTx2 := p.Flatten()
resp, err := client.SubmitTxAndWait(flattenedTx2, &wstypes.SubmitOptions{
Autofill: true,
Wallet: &w,
})
if err != nil {
fmt.Println(err)
return
}
fmt.Println("✅ Payment submitted via SubmitTxAndWait")
fmt.Printf("🌐 Hash: %s\n", resp.Hash)
fmt.Printf("🌐 Validated: %t\n", resp.Validated)
if err := client.Connect(); err != nil {
fmt.Println(err)
return
}
if !client.IsConnected() {
fmt.Println("❌ Failed to connect to testnet")
return
}
fmt.Println("✅ Connected to testnet")
fmt.Println()
// Example credentials
const WalletSeed = "sEd7zwWAu7vXMCBkkzokJHEXiKw2B2s"
w, err := wallet.FromSeed(WalletSeed, "")
if err != nil {
fmt.Println(err)
return
}
// Funding the wallet
fmt.Println("⏳ Funding wallet...")
if err := client.FundWallet(&w); err != nil {
fmt.Println(err)
return
}
fmt.Println("💸 Wallet funded")
fmt.Println()
xrpAmount, err := currency.XrpToDrops("1")
if err != nil {
fmt.Println(err)
return
}
xrpAmountInt, err := strconv.ParseInt(xrpAmount, 10, 64)
if err != nil {
fmt.Println(err)
return
}
// Prepare a payment transaction
p := &transaction.Payment{
BaseTx: transaction.BaseTx{
Account: types.Address(w.GetAddress()),
},
Destination: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
Amount: types.XRPCurrencyAmount(xrpAmountInt),
DeliverMax: types.XRPCurrencyAmount(xrpAmountInt),
}
flattenedTx := p.Flatten()
if err := client.Autofill(&flattenedTx); err != nil {
fmt.Println(err)
return
}
// Sign the transaction using the wallet
txBlob, _, err := w.Sign(flattenedTx)
if err != nil {
fmt.Println(err)
return
}
// Submit the transaction and wait for the result
res_blob, err := client.SubmitTxBlobAndWait(txBlob, false)
if err != nil {
fmt.Println(err)
return
}
// Example with SubmitTxAndWait
flattenedTx2 := p.Flatten()
res_flat, err := client.SubmitTxAndWait(flattenedTx2, &wstypes.SubmitOptions{
Autofill: true,
Wallet: &w,
})
if err != nil {
fmt.Println(err)
return
}
// Wait for validation -------------------------------------------------------
// SubmitTxBlobAndWait() handles this automatically, but it can take 4-7s.
// Check transaction results -------------------------------------------------
fmt.Printf("🌐 Hash: %s\n", res_blob.Hash)
fmt.Printf("🌐 Meta: %t\n", res_blob.Meta)
res, _ := client.Request(&transactions.TxRequest{
Transaction: res_flat.Hash.String(),
})
fmt.Printf("🌐 Result: %s\n", res.Result)
}

View File

@@ -14,6 +14,7 @@ These client libraries simplify some of the common work of accessing and process
| Language | Library Name | Get Started | API Reference | Source Code |
|---------------------------------|---------------------------|-------------|--------------|-------------|
| **Python** | `xrpl-py` | [Get Started Using Python](../tutorials/python/build-apps/get-started.md) | [API Reference](https://xrpl-py.readthedocs.io/) | [Repo](https://github.com/XRPLF/xrpl-py) |
| **GoLang** | `xrpl-go` | [Get Started Using Go](../tutorials/go/build-apps/get-started.md) | [API Reference](https://pkg.go.dev/github.com/Peersyst/xrpl-go) | [Repo](https://github.com/Peersyst/xrpl-go) |
| **JavaScript** / **TypeScript** | `xrpl.js` | [Get Started](../tutorials/javascript/build-apps/get-started.md) | [API Reference](https://js.xrpl.org/) | [Repo](https://github.com/XRPLF/xrpl.js) |
| **JavaScript** / **TypeScript** | `xrpl-client` | [Get Started](https://jsfiddle.net/WietseWind/35az6p1b/) | [NPM Reference](https://www.npmjs.com/package/xrpl-client) | [Repo](https://github.com/XRPL-Labs/xrpl-client) |
| **JavaScript** / **TypeScript** | `xrpl-accountlib` | [Get Started](https://jsfiddle.net/WietseWind/gkefpnu0/) | [NPM Reference](https://www.npmjs.com/package/xrpl-accountlib) | [Repo](https://github.com/WietseWind/xrpl-accountlib) |

View File

@@ -16,6 +16,8 @@ Use these libraries to access the XRP Ledger from your programming language of c
{% xrpl-card title="Python" body="xrpl.py - a pure Python library" href="https://xrpl-py.readthedocs.io/" image="/img/logos/python.svg" imageAlt="Python logo" /%}
{% xrpl-card title="GoLang" body="xrpl.go - a pure GoLang library" href="https://pkg.go.dev/github.com/Peersyst/xrpl-go" image="/img/logos/golang.svg" imageAlt="GoLang logo" /%}
{% xrpl-card title="Java" body="xrpl4j - a pure Java library" href="https://javadoc.io/doc/org.xrpl/" image="/img/logos/java.svg" imageAlt="Java logo" /%}
{% /card-grid %}

View File

@@ -0,0 +1,153 @@
---
html: get-started-using-golang-library.html
parent: golang.html
funnel: Build
doc_type: Tutorials
category: Get Started
seo:
description: Build a GoLang application that interacts with the XRP Ledger.
top_nav_name: GoLang
top_nav_grouping: Get Started
labels:
- Development
showcase_icon: assets/img/logos/golang.svg
---
# Get Started Using GoLang Library
This tutorial walks you through the basics of building an XRP Ledger-connected application using [`xrpl-go`](https://github.com/Peersyst/xrpl-go), a pure GoLang library built to interact with the XRP Ledger.
This tutorial is intended for beginners and should take no longer than 30 minutes to complete.
## Learning Goals
In this tutorial, you'll learn:
- The basic building blocks of XRP Ledger-based applications.
- How to connect to the XRP Ledger using `xrpl-go`.
- How to get an account on the [Testnet](/resources/dev-tools/xrp-faucets) using `xrpl-go`.
- How to use the `xrpl-go` library to look up information about an account on the XRP Ledger.
- How to put these steps together to create a Java app.
## Requirements
Requiring Go version `1.22.0` and later.
[Download latest Go version](https://go.dev/dl/)
## Installation
The [`xrpl-go` library](https://github.com/Peersyst/xrpl-go) is available on
Start a new project (or use an existing one) and install the `xrpl-go` library via Go modules:
```bash
# Initialize your module (if you haven't already)
go mod init your-module-name
# Fetch the latest version of xrpl-go
go get -u github.com/Peersyst/xrpl-go
```
## Start Building
When you're working with the XRP Ledger, there are a few things you'll need to manage, whether you're adding XRP to your [account](../../../concepts/accounts/index.md), integrating with the [decentralized exchange](../../../concepts/tokens/decentralized-exchange/index.md), or [issuing tokens](../../../concepts/tokens/index.md). This tutorial walks you through basic patterns common to getting started with all of these use cases and provides sample code for implementing them.
Here are the basic steps you'll need to cover for almost any XRP Ledger project:
1. [Connect to the XRP Ledger.](#1-connect-to-the-xrp-ledger)
1. [Get an account.](#2-get-account)
1. [Query the XRP Ledger.](#3-query-the-xrp-ledger)
### 1. Connect to the XRP Ledger
To make queries and submit transactions, you need to connect to the XRP Ledger. To do this with `xrpl-go`, you have two main options:
1. Via `websocket`: {% code-snippet file="/_code-samples/get-started/go/base/ws/main.go from="// Define the network client" before="// ... custom code goes here" language="go" /%}
2. Via `RPC`: {% code-snippet file="/_code-samples/get-started/go/base/rpc/main.go from="// Define the network client" before="// Ping the network (used to avoid Go unused variable error, but useful to check connectivity)" language="go" /%}
#### Connect to the production XRP Ledger
The sample code in the previous section shows you how to connect to the Testnet, which is a [parallel network](../../../concepts/networks-and-servers/parallel-networks.md) for testing where the money has no real value. When you're ready to integrate with the production XRP Ledger, you'll need to connect to the Mainnet. You can do that in two ways:
- By [installing the core server](../../../infrastructure/installation/index.md) (`rippled`) and running a node yourself. The core server connects to the Mainnet by default, but you can [change the configuration to use Testnet or Devnet](../../../infrastructure/configuration/connect-your-rippled-to-the-xrp-test-net.md). [There are good reasons to run your own core server](../../../concepts/networks-and-servers/index.md#reasons-to-run-your-own-server). If you run your own server, you can connect to it like so:
```go
import "github.com/Peersyst/xrpl-go/xrpl/websocket"
const MyServer := "http://localhost:5005/"
client := websocket.NewClient(websocket.NewClientConfig().WithHost(MyServer))
```
See the example [core server config file](https://github.com/XRPLF/rippled/blob/c0a0b79d2d483b318ce1d82e526bd53df83a4a2c/cfg/rippled-example.cfg#L1562) for more information about default values.
- By using one of the available [public servers][]:
```go
import "github.com/Peersyst/xrpl-go/xrpl/websocket"
const PublicServer = "wss://xrplcluster.com/"
client := websocket.NewClient(websocket.NewClientConfig().WithHost(PublicServer))
```
### 2. Get account
In `xrpl-go`, account creation and key management live in the wallet package, and on Testnet you can use the built-in faucet provider on your WebSocket client to fund a brand-new account immediately.
Here we spin up a Testnetconnected WebSocket client, generate a fresh ED25519 wallet, then fund it automatically via the public faucet.
```go
client := websocket.NewClient(
websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233").
WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
)
defer client.Disconnect()
if err := client.Connect(); err != nil {
fmt.Println(err)
return
}
w, err := wallet.New(crypto.ED25519())
if err != nil {
fmt.Println(err)
return
}
if err := client.FundWallet(&w); err != nil {
fmt.Println(err)
return
}
```
This constructor returns a Go `Wallet` value with the following fields:
```go
type Wallet struct {
PublicKey string // the hex-encoded public key
PrivateKey string // the hex-encoded private key
ClassicAddress types.Address // the XRPL “r…” address
Seed string // the base58 seed
}
```
If you already have a seed encoded in [base58][], you can make a `Wallet` instance from it like this:
```go
w, err := wallet.FromSeed("sn3nxiW7v8KXzPzAqzyHXbSSKNuN9", "")
```
### 3. Query the XRP Ledger
You can query the XRP Ledger to get information about [a specific account](../../../references/http-websocket-apis/public-api-methods/account-methods/index.md), [a specific transaction](../../../references/http-websocket-apis/public-api-methods/transaction-methods/tx.md), the state of a [current or a historical ledger](../../../references/http-websocket-apis/public-api-methods/ledger-methods/index.md), and [the XRP Ledger's decentralized exchange](../../../references/http-websocket-apis/public-api-methods/path-and-order-book-methods/index.md). You need to make these queries, among other reasons, to look up account info to follow best practices for [reliable transaction submission](../../../concepts/transactions/reliable-transaction-submission.md).
You can use either the Client's `request()` method to access the XRP Ledger's [WebSocket API](../../../references/http-websocket-apis/api-conventions/request-formatting.md). For example:
{% code-snippet file="/_code-samples/get-tx/go/main.go" from="// Get the latest validated ledger" language="go" /%}
Or use the [`websocket` or `rpc` packages] getter methods:
{% code-snippet file="/_code-samples/get-started/go/get-acc-info/ws/main.go" from="// Get info from" before="// Get info about" language="go" /%}
## Keep on Building
Now that you know how to use `xrpl.js` to connect to the XRP Ledger, get an account, and look up information about it, you can also:
- [Send XRP](../../how-tos/send-xrp.md).

View File

@@ -0,0 +1,13 @@
---
html: build-apps-with-golang.html
parent: golang.html
top_nav_grouping: Article Types
metadata:
indexPage: true
---
# Build Applications with GoLang Library
Build full-featured applications in GoLang.
{% child-pages /%}

View File

@@ -0,0 +1,24 @@
---
html: golang.html
parent: tutorials.html
top_nav_grouping: Article Types
metadata:
indexPage: true
---
# GoLang
You can create your own interface to try out the capabilities and support your specific business needs. These tutorials build a test harness interface to try out features of the XRP Ledger. The harness displays multiple accounts, so that you can transfer tokens from one account to the other and see the results in real time.
Typically, the example functions involve four steps.
- Connect to the XRP Ledger and instantiate your wallet.
- Make changes to the XRP Ledger using transactions.
- Get the state of accounts and tokens on the XRP Ledger using requests.
- Disconnect from the XRP Ledger.
Once familiar with the library functions, you can build sample applications in GoLang. We anticipate that the applications you build greatly improve upon these examples. Your feedback and contributions are most welcome.
## Tutorial Modules
{% child-pages /%}

View File

@@ -28,7 +28,7 @@ To interact with the XRP Ledger, you need to set up a dev environment with the n
- **Python** with the [`xrpl-py` library](https://xrpl-py.readthedocs.io/). See [Get Started using Python](../python/build-apps/get-started.md) for setup steps.
- **Java** with the [xrpl4j library](https://github.com/XRPLF/xrpl4j). See [Get Started Using Java](../java/build-apps/get-started.md) for setup steps.
- **PHP** with the [XRPL_PHP library](https://github.com/AlexanderBuzz/xrpl-php). See [Get Started Using PHP](../php/build-apps/get-started.md) for setup steps.
- **GoLang** with the [xrpl-go library](https://github.com/Peersyst/xrpl-go). See [Get Started Using GoLang](../go/build-apps/get-started.md) for setup steps.
## Send a Payment on the Test Net
@@ -54,6 +54,10 @@ To transact on the XRP Ledger, you need an address and secret key, and some XRP.
{% code-snippet file="/_code-samples/send-xrp/php/send-xrp.php" from="// Example credentials" before="// Create" language="php" /%}
{% /tab %}
{% tab label="GoLang" %}
{% code-snippet file="/_code-samples/send-xrp/go/ws/main.go" from="// Example credentials" before="// Funding" language="go" /%}
{% /tab %}
{% /tabs %}
The secret key shown here is for example only. For development purposes, you can get your own credentials, pre-funded with XRP, on the Testnet using the following interface:
@@ -87,6 +91,10 @@ The following code connects to a public Testnet servers:
{% code-snippet file="/_code-samples/send-xrp/php/send-xrp.php" from="// Create a client" before="// Transaction definition" language="php" /%}
{% /tab %}
{% tab label="GoLang" %}
{% code-snippet file="/_code-samples/send-xrp/go/ws/main.go" from="func main()" before="if !client.IsConnected() " language="go" /%}
{% /tab %}
{% /tabs %}
For this tutorial, click the following button to connect:
@@ -142,6 +150,10 @@ Here's an example of preparing the above payment:
{% code-snippet file="/_code-samples/send-xrp/php/send-xrp.php" from="// Transaction definition" before="// Sign" language="php" /%}
{% /tab %}
{% tab label="GoLang" %}
{% code-snippet file="/_code-samples/send-xrp/go/ws/main.go" from="// Prepare " before="// Sign" language="go" /%}
{% /tab %}
{% /tabs %}
{% interactive-block label="Prepare" steps=$frontmatter.steps %}
@@ -172,6 +184,7 @@ Signing a transaction uses your credentials to authorize the transaction on your
- **Python:** Use the [`xrpl.transaction.safe_sign_transaction()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.safe_sign_transaction) with a model and `Wallet` object.
- **Java:** Use a [`SignatureService`](https://javadoc.io/doc/org.xrpl/xrpl4j-crypto-core/latest/org/xrpl/xrpl4j/crypto/signing/SignatureService.html) instance to sign the transaction. For this tutorial, use the [`SingleKeySignatureService`](https://javadoc.io/doc/org.xrpl/xrpl4j-crypto-bouncycastle/latest/org/xrpl/xrpl4j/crypto/signing/SingleKeySignatureService.html).
- **PHP:** Use a [`sign()` method of a `Wallet` instance](https://alexanderbuzz.github.io/xrpl-php-docs/wallet.html#signing-a-transaction) instance to sign the transaction. The input to this step is a completed array of transaction instructions.
- **GoLang:** Use the [`Sign()` method of the `Wallet` package](https://pkg.go.dev/github.com/Peersyst/xrpl-go@v0.1.12/xrpl/wallet) to sign the transaction.
{% tabs %}
@@ -191,6 +204,10 @@ Signing a transaction uses your credentials to authorize the transaction on your
{% code-snippet file="/_code-samples/send-xrp/php/send-xrp.php" from="// Sign" before="// Submit" language="php" /%}
{% /tab %}
{% tab label="GoLang" %}
{% code-snippet file="/_code-samples/send-xrp/go/ws/main.go" from="// Sign" before="// Submit" language="go" /%}
{% /tab %}
{% /tabs %}
The result of the signing operation is a transaction object containing a signature. Typically, XRP Ledger APIs expect a signed transaction to be the hexadecimal representation of the transaction's canonical [binary format](../../references/protocol/binary-format.md), called a "blob".
@@ -199,6 +216,7 @@ The result of the signing operation is a transaction object containing a signatu
- In `xrpl-py`, you can get the transaction's hash in the response to submitting it in the next step.
- In xrpl4j, `SignatureService.sign` returns a `SignedTransaction`, which contains the transaction's hash, which you can use to look up the transaction later.
- In `XRPL_PHP`, the signing API also returns the transaction's ID, or identifying hash, which you can use to look up the transaction later. This is a 64-character hexadecimal string that is unique to this transaction.
- In `xrpl-go`, the signing API also returns the transaction's ID, or identifying hash, which you can use to look up the transaction later. This is a 64-character hexadecimal string that is unique to this transaction.
{% interactive-block label="Sign" steps=$frontmatter.steps %}
@@ -217,6 +235,7 @@ Now that you have a signed transaction, you can submit it to an XRP Ledger serve
- **Python:** Use the [`xrpl.transaction.submit_and_wait()` method](https://xrpl-py.readthedocs.io/en/stable/source/xrpl.transaction.html#xrpl.transaction.submit_and_wait) to submit a transaction to the network and wait for a response.
- **Java:** Use the [`XrplClient.submit(SignedTransaction)` method](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#submit(org.xrpl.xrpl4j.crypto.signing.SignedTransaction)) to submit a transaction to the network. Use the [`XrplClient.ledger()`](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#ledger(org.xrpl.xrpl4j.model.client.ledger.LedgerRequestParams)) method to get the latest validated ledger index.
- **PHP:** Use the [`submitAndWait()` method of the Client](https://alexanderbuzz.github.io/xrpl-php-docs/client.html) to submit a transaction to the network and wait for the response.
- **GoLang:** Use [`SubmitTxAndWait()` or `SubmitTxBlobAndWait()` methods os the Client](https://pkg.go.dev/github.com/Peersyst/xrpl-go@v0.1.12/xrpl/websocket#Client.SubmitTxAndWait) to submit a transaction to the network and wait for the response.
{% tabs %}
@@ -236,6 +255,10 @@ Now that you have a signed transaction, you can submit it to an XRP Ledger serve
{% code-snippet file="/_code-samples/send-xrp/php/send-xrp.php" from="// Submit" before="// Wait" language="php" /%}
{% /tab %}
{% tab label="GoLang" %}
{% code-snippet file="/_code-samples/send-xrp/go/ws/main.go" from="// Submit" before="// Wait" language="go" /%}
{% /tab %}
{% /tabs %}
This method returns the **tentative** result of trying to apply the transaction to the open ledger. This result _can_ change when the transaction is included in a validated ledger: transactions that succeed initially might ultimately fail, and transactions that fail initially might ultimately succeed. Still, the tentative result often matches the final result, so it's OK to get excited if you see `tesSUCCESS` here. 😁
@@ -273,6 +296,8 @@ Most transactions are accepted into the next ledger version after they're submit
- **PHP:** If you used the [`.submitAndWait()` method](https://alexanderbuzz.github.io/xrpl-php-docs/client.html), you can wait until the returned Promise resolves. Other, more asynchronous approaches are also possible.
- **GoLang:** If you used the `SubmitTxAndWait()` or `SubmitTxBlobAndWait()` methods, the client will handle submission and wait until the transaction is confirmed in a ledger. Internally, these methods use a polling mechanism, querying the transaction status with the client's `Request()` method and a `TxRequest`.
{% tabs %}
{% tab label="JavaScript" %}
@@ -291,6 +316,10 @@ Most transactions are accepted into the next ledger version after they're submit
{% code-snippet file="/_code-samples/send-xrp/php/send-xrp.php" from="// Wait" before="// Check" language="php" /%}
{% /tab %}
{% tab label="GoLang" %}
{% code-snippet file="/_code-samples/send-xrp/go/ws/main.go" from="// Wait" before="// Check" language="go" /%}
{% /tab %}
{% /tabs %}
{% partial file="/docs/_snippets/interactive-tutorials/wait-step.md" /%}
@@ -310,6 +339,8 @@ To know for sure what a transaction did, you must look up the outcome of the tra
- **PHP:** Use the response from `submitAndWait()` or call the `tx method` using [`$client->syncRequest()`](https://alexanderbuzz.github.io/xrpl-php-docs/client.html).
- **GoLang:** Use the response from `SubmitTxAndWait()` or `SubmitTxBlobAndWait()`, or manually query the transaction status using a `TxRequest` with the client's `Request()` method.
{% tabs %}
{% tab label="JavaScript" %}
@@ -328,6 +359,10 @@ To know for sure what a transaction did, you must look up the outcome of the tra
{% code-snippet file="/_code-samples/send-xrp/php/send-xrp.php" from="// Check" language="php" /%}
{% /tab %}
{% tab label="GoLang" %}
{% code-snippet file="/_code-samples/send-xrp/go/ws/main.go" from="// Check" language="go" /%}
{% /tab %}
{% /tabs %}
{% admonition type="warning" name="Caution" %}XRP Ledger APIs may return tentative results from ledger versions that have not yet been validated. For example, in [tx method][] response, be sure to look for `"validated": true` to confirm that the data comes from a validated ledger version. Transaction results that are not from a validated ledger version are subject to change. For more information, see [Finality of Results](../../concepts/transactions/finality-of-results/index.md).{% /admonition %}
@@ -391,6 +426,16 @@ print_r("Seed: " . $wallet->getSeed()); // Example: sp6JS7f14BuwFY8Mw6bTtLKWauoU
```
{% /tab %}
{% tab label="GoLang" %}
```go
wallet, err := wallet.New(crypto.ED25519())
fmt.Println("🌐 Classic Address:", wallet.ClassicAddress) // Example: r9ESeQQswbTxV8neiDTLTHXbXfUwiihyJk
fmt.Println("🌐 Seed:", wallet.Seed) // Example: sEd7XGFGSWteam777HQHvw7vHypEWy2
```
{% /tab %}
{% /tabs %}
{% admonition type="danger" name="Warning" %}You should only use an address and secret that you generated securely, on your local machine. If another computer generated the address and secret and sent it to you over a network, it's possible that someone else on the network may see that information. If they do, they'll have as much control over your XRP as you do. It's also recommended not to use the same address for the Testnet and Mainnet, because transactions that you created for use on one network could also be valid to execute on the other network, depending on the parameters you provided.{% /admonition %}
@@ -433,6 +478,20 @@ $client = new JsonRpcClient("https://xrplcluster.com");
```
{% /tab %}
{% tab label="GoLang" %}
```go
client := websocket.NewClient(
websocket.NewClientConfig().
WithHost("wss://xrplcluster.com")
)
if err := client.Connect(); err != nil {
fmt.Println(err)
return
}
```
{% /tab %}
{% /tabs %}
If you [install `rippled`](../../infrastructure/installation/index.md) yourself, it connects to the production network by default. (You can also [configure it to connect to the test net](../../infrastructure/configuration/connect-your-rippled-to-the-xrp-test-net.md) instead.) After the server has synced (typically within about 15 minutes of starting it up), you can connect to it locally, which has [various benefits](../../concepts/networks-and-servers/index.md). The following example shows how to connect to a server running the default configuration:
@@ -469,6 +528,20 @@ $client = new JsonRpcClient("http://localhost:5005");
```
{% /tab %}
{% tab label="GoLang" %}
```go
client := websocket.NewClient(
websocket.NewClientConfig().
WithHost("http://localhost:5005")
)
if err := client.Connect(); err != nil {
fmt.Println(err)
return
}
```
{% /tab %}
{% /tabs %}
{% admonition type="success" name="Tip" %}The local connection uses an unencrypted protocol (`ws` or `http`) rather than the TLS-encrypted version (`wss` or `https`). This is secure only because the communications never leave the same machine, and is easier to set up because it does not require a TLS certificate. For connections on an outside network, always use `wss` or `https`.{% /admonition %}

View File

@@ -16,7 +16,7 @@ These tutorials walk you through the basics of building a very simple XRP Ledger
{% xrpl-card title="Python" body="Using xrpl.py, a pure Python library." href="/docs/tutorials/python/" image="/img/logos/python.svg" imageAlt="Python logo" /%}
<br/>
{% xrpl-card title="GoLang" body="Using xrpl-go, a pure GoLang library." href="/docs/tutorials/go/" image="/img/logos/golang.svg" imageAlt="GoLang logo" /%}
{% xrpl-card title="Java" body="Using xrpl4j, a pure Java library." href="/docs/tutorials/java/" image="/img/logos/java.svg" imageAlt="Java logo" /%}

View File

@@ -249,6 +249,13 @@
- page: docs/tutorials/python/compliance/index.md
items:
- page: docs/tutorials/python/compliance/verify-credential.md
- page: docs/tutorials/go/index.md
expanded: false
items:
- page: docs/tutorials/go/build-apps/index.md
expanded: false
items:
- page: docs/tutorials/go/build-apps/get-started.md
- page: docs/tutorials/java/index.md
expanded: false
items:
@@ -473,6 +480,9 @@
- label: Ruby Client Library
href: https://www.rubydoc.info/gems/xrbp
external: true
- label: GoLang Client Library
href: https://pkg.go.dev/github.com/Peersyst/xrpl-go
external: true
- page: docs/references/http-websocket-apis/index.md
expanded: false
items:

View File

@@ -88,6 +88,7 @@
- page: ./docs/tutorials/python/index.md
- page: ./docs/tutorials/java/index.md
- page: ./docs/tutorials/php/index.md
- page: ./docs/tutorials/go/index.md
- page: ./docs/tutorials/http-websocket-apis/index.md
- group: Resources