Skip to content

Add xrpl-go examples and references to xrpl-dev-portal #3211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

banasa44
Copy link

Add xrpl-go examples and references to xrpl-dev-portal

Description

This PR aims to include the xrpl-go library into the XRPLF xrpl-dev-portal repository. Including code samples, and references to it in the documentation site.

Changes

  • Add code samples.
  • Add link in the nav-bar
  • Add card in Tutorials section
  • Add GoLang Docs in Tutorial section (Build apps - get started)
  • Add GoLang in send-xrp How to's
  • Add GoLang in References, and in Client Libraries

Notes

Notice that all the references to xrpl-go package specification and GitHub repository still points to PeerSyst's. A replace all might be done when moving the repository to XRPLF GitHub account.

@banasa44 banasa44 marked this pull request as ready for review July 23, 2025 08:57
@oeggert oeggert requested a review from maria-robobug August 11, 2025 18:57
Comment on lines +347 to +356
<div className="col langs">
<Link to="/docs/tutorials/go/">
<img
alt="GoLang Logo"
src={require("../static/img/logos/golang.svg")}
className="circled-logo"
/>
<h5 className="btn-arrow">{translate("GoLang")}</h5>
</Link>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is duplicated?

@@ -13,6 +13,7 @@ For other programming languages, you can access the XRP Ledger through the [HTTP
| 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) |
Copy link
Contributor

@maria-robobug maria-robobug Aug 15, 2025

Choose a reason for hiding this comment

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

Let's stick with the official name, "Go".

Suggested change
| **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) |
| **Go** | `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) |

showcase_icon: assets/img/logos/golang.svg
---

# Get Started Using GoLang Library
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Get Started Using GoLang Library
# Get Started Using Go Library

@@ -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" /%}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{% 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="Go" body="xrpl.go - a pure Go library" href="https://pkg.go.dev/github.com/Peersyst/xrpl-go" image="/img/logos/golang.svg" imageAlt="Go logo" /%}

@@ -469,6 +476,9 @@
- label: Ruby Client Library
href: https://www.rubydoc.info/gems/xrbp
external: true
- label: GoLang Client Library
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- label: GoLang Client Library
- label: Go Client Library

@@ -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" /%}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{% 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="Go" body="Using xrpl-go, a pure Go library." href="/docs/tutorials/go/" image="/img/logos/golang.svg" imageAlt="Go logo" /%}

<div className="col langs">
<Link to="/docs/tutorials/go/">
<img
alt="GoLang Logo"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
alt="GoLang Logo"
alt="Go Logo"


## Requirements

Requiring Go version `1.22.0` and later.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Requiring Go version `1.22.0` and later.
To follow this tutorial, you should have Go version `1.22.0` or later installed.

## Requirements

Requiring Go version `1.22.0` and later.
[Download latest Go version](https://go.dev/dl/)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[Download latest Go version](https://go.dev/dl/)
[Download latest Go version](https://go.dev/dl/).

Comment on lines +56 to +58
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.](#1.-connect-to-the-xrp-ledger)
2. [Get an account.](#2.-get-account)
3. [Query the XRP Ledger.](#3.-query-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`:
Copy link
Contributor

@maria-robobug maria-robobug Aug 15, 2025

Choose a reason for hiding this comment

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

Suggested change
1. Via `websocket`:
1. Via WebSocket:


### 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 (or RPC) client to fund a brand-new account immediately.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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 (or RPC) client to fund a brand-new account immediately.
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 (or RPC) client to fund a brand-new account immediately.

return
}

fmt.Println("✅ Batch transaction submitted")
Copy link
Contributor

@maria-robobug maria-robobug Aug 15, 2025

Choose a reason for hiding this comment

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

Please avoid using emojis in the example code. Some environments may not render emojis reliably, and it keeps our examples universally readable.

Comment on lines +347 to +356
<div className="col langs">
<Link to="/docs/tutorials/go/">
<img
alt="GoLang Logo"
src={require("../static/img/logos/golang.svg")}
className="circled-logo"
/>
<h5 className="btn-arrow">{translate("GoLang")}</h5>
</Link>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<div className="col langs">
<Link to="/docs/tutorials/go/">
<img
alt="GoLang Logo"
src={require("../static/img/logos/golang.svg")}
className="circled-logo"
/>
<h5 className="btn-arrow">{translate("GoLang")}</h5>
</Link>
</div>

Remove this duplicate.

Comment on lines +2 to +6
html: get-started-using-golang-library.html
parent: golang.html
funnel: Build
doc_type: Tutorials
category: Get Started
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
html: get-started-using-golang-library.html
parent: golang.html
funnel: Build
doc_type: Tutorials
category: Get Started

You can remove these frontmatter values.

top_nav_grouping: Get Started
labels:
- Development
showcase_icon: assets/img/logos/golang.svg
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
showcase_icon: assets/img/logos/golang.svg

Comment on lines +2 to +4
html: build-apps-in-golang.html
parent: golang.html
top_nav_grouping: Article Types
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
html: build-apps-in-golang.html
parent: golang.html
top_nav_grouping: Article Types

You can remove this frontmatter--it's deprecated.

Comment on lines +2 to +4
html: golang.html
parent: tutorials.html
top_nav_grouping: Article Types
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
html: golang.html
parent: tutorials.html
top_nav_grouping: Article Types

@@ -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" %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{% tab label="GoLang" %}
{% tab label="Go" %}

@@ -391,6 +426,16 @@ print_r("Seed: " . $wallet->getSeed()); // Example: sp6JS7f14BuwFY8Mw6bTtLKWauoU
```
{% /tab %}

{% tab label="GoLang" %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{% tab label="GoLang" %}
{% tab label="Go" %}

Comment on lines +433 to +434
fmt.Println("🌐 Classic Address:", wallet.ClassicAddress) // Example: r9ESeQQswbTxV8neiDTLTHXbXfUwiihyJk
fmt.Println("🌐 Seed:", wallet.Seed) // Example: sEd7XGFGSWteam777HQHvw7vHypEWy2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
fmt.Println("🌐 Classic Address:", wallet.ClassicAddress) // Example: r9ESeQQswbTxV8neiDTLTHXbXfUwiihyJk
fmt.Println("🌐 Seed:", wallet.Seed) // Example: sEd7XGFGSWteam777HQHvw7vHypEWy2
fmt.Println("Classic Address:", wallet.ClassicAddress) // Example: r9ESeQQswbTxV8neiDTLTHXbXfUwiihyJk
fmt.Println("Seed:", wallet.Seed) // Example: sEd7XGFGSWteam777HQHvw7vHypEWy2

@@ -433,6 +478,20 @@ $client = new JsonRpcClient("https://xrplcluster.com");
```
{% /tab %}

{% tab label="GoLang" %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{% tab label="GoLang" %}
{% tab label="Go" %}

@@ -469,6 +528,20 @@ $client = new JsonRpcClient("http://localhost:5005");
```
{% /tab %}

{% tab label="GoLang" %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{% tab label="GoLang" %}
{% tab label="Go" %}

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- [GoLang](https://xrpl.org/get-started-using-golang.html)
- [Go](https://xrpl.org/get-started-using-go.html)

Comment on lines +65 to +78
```go
// Define the network client
client := websocket.NewClient(websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233"))

// Disconnect the client when done. (Defer executes at the end of the function)
defer client.Disconnect()

// Connect to the network
if err := client.Connect(); err != nil {
fmt.Println(err)
return
}
```
Copy link
Contributor

@maria-robobug maria-robobug Aug 18, 2025

Choose a reason for hiding this comment

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

Since we have a code sample for this (_code-samples/get-started/go/base/ws/main.go), please use the code-snippet tag to reference the snippet instead.

For example:

1. Via WebSocket:

    {% code-snippet file="/_code-samples/get-started/go/base/ws/main.go" from="func main()" language="go" /%}

Comment on lines +79 to +88
2. Via `RPC`:
```go
cfg, err := rpc.NewClientConfig("https://s.altnet.rippletest.net:51234/")
if err != nil {
panic(err)
}

// Initiate the network client
client := rpc.NewClient(cfg)
```
Copy link
Contributor

@maria-robobug maria-robobug Aug 18, 2025

Choose a reason for hiding this comment

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

Suggested change
2. Via `RPC`:
```go
cfg, err := rpc.NewClientConfig("https://s.altnet.rippletest.net:51234/")
if err != nil {
panic(err)
}
// Initiate the network client
client := rpc.NewClient(cfg)
```
2. Via RPC:
{% code-snippet file="/_code-samples/get-started/go/base/rpc/main.go" from="func main()" language="go" /%}

Comment on lines +12 to +13
client := websocket.NewClient(websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we add the WithFaucetProvider() function here since we are connecting to Testnet?

Suggested change
client := websocket.NewClient(websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233"))
client := websocket.NewClient(websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233").
WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
)


func main() {
// Define the network client configuration
cfg, err := rpc.NewClientConfig("https://s.altnet.rippletest.net:51234/")
Copy link
Contributor

@maria-robobug maria-robobug Aug 18, 2025

Choose a reason for hiding this comment

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

Shouldn't we add the WithFaucetProvider() function here since we are connecting to Testnet?

Suggested change
cfg, err := rpc.NewClientConfig("https://s.altnet.rippletest.net:51234/")
cfg, err := rpc.NewClientConfig(
"https://s.altnet.rippletest.net:51234/",
rpc.WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
)


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).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- [Send XRP](../../how-tos/send-xrp.md).
- [Send XRP](../../how-tos/send-xrp.md).
{% raw-partial file="/docs/_snippets/common-links.md" /%}


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:
Copy link
Contributor

@maria-robobug maria-robobug Aug 18, 2025

Choose a reason for hiding this comment

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

Not sure this actually describes the Go code correctly. Change to:

Suggested change
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:
Use the Client's `Request()` method to access the XRP Ledger's [WebSocket API](../../../references/http-websocket-apis/api-conventions/request-formatting.md). For example:

Comment on lines +107 to +111
```go
import "github.com/Peersyst/xrpl-go/xrpl/websocket"
const PublicServer = "wss://xrplcluster.com/"
client := websocket.NewClient(websocket.NewClientConfig().WithHost(PublicServer))
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```go
import "github.com/Peersyst/xrpl-go/xrpl/websocket"
const PublicServer = "wss://xrplcluster.com/"
client := websocket.NewClient(websocket.NewClientConfig().WithHost(PublicServer))
```
```go
import "github.com/Peersyst/xrpl-go/xrpl/websocket"
const PUBLIC_SERVER = "wss://xrplcluster.com/"
func main() {
client := websocket.NewClient(websocket.NewClientConfig().WithHost(PUBLIC_SERVER))
// ... custom code goes here
}

Comment on lines +97 to +101
```go
import "github.com/Peersyst/xrpl-go/xrpl/websocket"
const MyServer := "ws://localhost:6006/"
client := websocket.NewClient(websocket.NewClientConfig().WithHost(MyServer))
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```go
import "github.com/Peersyst/xrpl-go/xrpl/websocket"
const MyServer := "ws://localhost:6006/"
client := websocket.NewClient(websocket.NewClientConfig().WithHost(MyServer))
```
```go
import "github.com/Peersyst/xrpl-go/xrpl/websocket"
const MY_SERVER = "ws://localhost:6006/"
func main() {
client := websocket.NewClient(websocket.NewClientConfig().WithHost(MY_SERVER))
// ... custom code goes here
}


## 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:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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:
Now that you know how to use `xrpl-go` to connect to the XRP Ledger, get an account, and look up information about it, you can also:


{% 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](https://pkg.go.dev/github.com/Peersyst/[email protected]/xrpl/websocket#Client.GetAccountChannels) getter methods:
Copy link
Contributor

@maria-robobug maria-robobug Aug 18, 2025

Choose a reason for hiding this comment

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

Suggested change
Or use the [`websocket` or `rpc` packages](https://pkg.go.dev/github.com/Peersyst/[email protected]/xrpl/websocket#Client.GetAccountChannels) getter methods:
Or, use the getter methods from the [`websocket`](https://pkg.go.dev/github.com/Peersyst/[email protected]/xrpl/websocket) or [`rpc`](https://pkg.go.dev/github.com/Peersyst/[email protected]/xrpl/rpc) packages:


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 (or RPC) client to fund a brand-new account immediately.

Here we spin up a Testnet‐connected WebSocket client, generate a fresh ED25519 wallet, then fund it automatically via the public faucet.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Here we spin up a Testnet‐connected WebSocket client, generate a fresh ED25519 wallet, then fund it automatically via the public faucet.
On Testnet, you can fund a new ED25519 account like this:

Comment on lines +120 to +131
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
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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
}

We've already shown the user how to connect with the client(s) in the previous step, so we probably don't need to show this again.

fmt.Println("⏳ Autofilling flattened multi batch transaction...")
if err := client.AutofillMultisigned(&flattenedMultiBatchTx, 1); err != nil {
fmt.Println("Autofill error:", err)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use panic(err) for all error handling in these code examples? I know it's not good practice for production code, but for documentation examples it should be fine.

Copy link
Contributor

@maria-robobug maria-robobug left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Added comments and suggestions.

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.

3 participants