diff --git a/_code-samples/simplexrpl/README.md b/_code-samples/simplexrpl/README.md new file mode 100644 index 00000000..74df7ac0 --- /dev/null +++ b/_code-samples/simplexrpl/README.md @@ -0,0 +1,3 @@ +# simpleXRPL Examples + +This directory contains runnable TypeScript examples that demonstrate `simpleXRPL` business operations. diff --git a/_code-samples/simplexrpl/getStarted.ts b/_code-samples/simplexrpl/getStarted.ts new file mode 100644 index 00000000..3fd05a8a --- /dev/null +++ b/_code-samples/simplexrpl/getStarted.ts @@ -0,0 +1,40 @@ +// This Get Started sample walks through the basics of using simpleXRPL. + +import { LocalSigner, SimpleXRPL } from 'simplexrpl' + +// --- Construct a connector --- +// The LocalSigner constructor is a self-custody option that signs locally. +// Intended for testing and development. +const signer = LocalSigner.fromEnv() + +// --- Initialize the client --- +const client = await SimpleXRPL.init({ + rippledUrl: 'wss://s.altnet.rippletest.net:51233', + faucetUrl: 'https://faucet.altnet.rippletest.net/accounts', + signers: [signer], +}) + +// --- Discover your accounts --- +// Connectors discover their accounts at init; the client merges them into one +// index keyed by XRPL address. +for (const [address, account] of client.accounts) { + console.log(`${address}: ${account.signer.kind}`) +} + +// Get the primary account used to submit vertical operations. +// No args returns the primary account. +const primary = client.resolveAccount() +console.log(`primary: ${primary.address}`) + +// Read an account's on-chain state. No args retrieves the primary account. +const state = await client.account.retrieve() +console.log(`balance (XRP): ${state.data.xrpBalance} | sequence: ${state.data.sequence}`) + +// --- Send an XRP transfer --- +const result = await client.xrp.transfer({ + to: 'rDestination00000000000000000000000', + amount: '10', +}) +console.log(`submitted: ${result.txHash}`) + +await client.disconnect() diff --git a/docs/_snippets/simplexrpl-amount.md b/docs/_snippets/simplexrpl-amount.md new file mode 100644 index 00000000..d605e52e --- /dev/null +++ b/docs/_snippets/simplexrpl-amount.md @@ -0,0 +1,16 @@ +The `Amount` type pairs a value with the asset it denominates: + +```ts +interface Amount { + asset: Asset // what is being moved + value: string // the quantity, as a decimal string in display units (e.g., '10.5') +} +``` + +Build the `asset` field with one of the asset constructors: + +| Constructor | Description | +| --- | --- | +| `XRP_ASSET` | XRP | +| `iou(currency, issuer)` | IOUs: `currency` is a 3-character code or 40-character hex; `issuer` is the issuer's r-address. | +| `mpt(mptIssuanceId, scale?)` | MPTs: `scale` is the decimal places between the display value and on-ledger base units (default `0`). | diff --git a/docs/_snippets/simplexrpl-response-fields.md b/docs/_snippets/simplexrpl-response-fields.md new file mode 100644 index 00000000..6c26e028 --- /dev/null +++ b/docs/_snippets/simplexrpl-response-fields.md @@ -0,0 +1,10 @@ +Every simpleXRPL write resolves to a `SubmissionResult` — a union tagged by `source`, with the backend's raw response preserved verbatim. Its common fields are: + +| Field | Type | Description | +| --- | --- | --- | +| `intent` | `T` | The method-specific output. See the method's return fields below. | +| `source` | `'rippled' \| 'custody' \| 'palisade'` | Which backend produced the result; discriminates `response`. | +| `response` | `TxResponse` \| custody record \| Palisade record | The backend's raw response, preserved verbatim. | +| `txHash` | `string` _(optional)_ | The XRPL transaction hash, once the transaction is on-ledger. | +| `intentId` | `string` _(optional)_ | The custodian intent id, when the path produced one. | +| `idempotencyKey` | `string` _(optional)_ | The UUIDv7 this submission carried. Pass it back as a later call's `idempotencyKey` to retry to the same intent. | diff --git a/docs/_snippets/simplexrpl-write-options.md b/docs/_snippets/simplexrpl-write-options.md new file mode 100644 index 00000000..9bd1b2ce --- /dev/null +++ b/docs/_snippets/simplexrpl-write-options.md @@ -0,0 +1,7 @@ +`options` is an optional second argument that sets the source account and overrides the fee. + +| Option | Type | Required | Description | +| --- | --- | --- | --- | +| `from` | `AccountSelector` | No | The account to act as — an r-address string, or an object `{ address }` or `{ signer, account? }`. Defaults to the primary signer's primary account. (For IOU verbs, this is the issuer.) | +| `fee` | `FeeIntent` | No | Fee override. Object shape:
`{ priority?: 'low' \| 'medium' \| 'high' }` | +| `idempotencyKey` | `string` | No | A prior submission's `idempotencyKey`, to retry to the same intent instead of creating a duplicate. Auto-generated when omitted. | diff --git a/docs/simpleXRPL/get-started.md b/docs/simpleXRPL/get-started.md new file mode 100644 index 00000000..a3301b76 --- /dev/null +++ b/docs/simpleXRPL/get-started.md @@ -0,0 +1,82 @@ +--- +seo: + description: Install simpleXRPL, construct a connector, initialize the client, discover your accounts, and send your first XRP Ledger payment. +labels: + - simpleXRPL + - SDK +--- + +# Get Started + +This tutorial takes you through the basics of sending your first operation on the XRP Ledger with **simpleXRPL**. + + +## Goals + +By the end of this tutorial, you will be able to: + +- Construct a connector. +- Initialize a client. +- Discover your accounts. +- Transfer XRP between accounts. + + +## Prerequisites + +To complete this tutorial, you should: + +- Have some familiarity with writing code in TypeScript. +- Have **Node.js version 20.19** or later. + + +## Source Code + +You can find the complete source code for this tutorial's examples in the [code samples section of this website's repository](https://github.com/ripple/opensource.ripple.com/tree/main/_code-samples/simplexrpl/) + + +## Steps + +### 1. Install dependencies + +```sh +npm install simplexrpl +``` + +### 2. Construct a connector + +A connector is a signing backend that determines how operations are executed and signed. This guide uses local signing with a `LocalSigner` constructor. This self-custody connector manages accounts and signs locally, making it ideal for testing and development. + +{% code-snippet file="/_code-samples/simplexrpl/getStarted.ts" language="ts" before="// --- Initialize the client ---" /%} + +For production you'd construct a custodian connector instead and pass it to `init` in place of (or alongside) the local one. See [Connectors](./references/connectors/index.md) for how to build each one; every vertical operation then works the same regardless of which connector owns the account. + +### 3. Initialize the client + +Initializing an account binds connectors to a network and builds the account index. + +{% code-snippet file="/_code-samples/simplexrpl/getStarted.ts" language="ts" from="// --- Initialize the client ---" before="// --- Discover your accounts ---" /%} + +- `signers[0]` is the default *primary* account used for operations if not specified. +- If you don't set a `signer`, the client is read-only and you will receive a `NoSignerError` when attempting write operations. + +### 4. Discover your accounts + +Connectors discover their accounts at initialization, and the client merges them into a single index keyed by XRPL account address. List them, resolve the primary, and read on-chain state. + +{% code-snippet file="/_code-samples/simplexrpl/getStarted.ts" language="ts" from="// --- Discover your accounts ---" before="// --- Send an XRP transfer ---" /%} + +### 5. Transfer XRP + +Operations are grouped into domain-specific verticals reached off the client. This guide sends XRP from the primary address to another. For a full list of vertical operations, see: [Verticals](./references/verticals/index.md). + +{% code-snippet file="/_code-samples/simplexrpl/getStarted.ts" language="ts" from="// --- Send an XRP transfer ---" /%} + + +## See Also + +- **References**: + - [LocalSigner.fromEnv()](./references/connectors/local.md#localsignerfromenv) + - [SimpleXRPL.init()](./references/client.md#simplexrplinit) + - [account.retrieve()](./references/verticals/account/retrieve.md) + - [xrp.transfer()](./references/verticals/xrp/transfer.md) + \ No newline at end of file diff --git a/docs/simpleXRPL/index.md b/docs/simpleXRPL/index.md new file mode 100644 index 00000000..4c501abd --- /dev/null +++ b/docs/simpleXRPL/index.md @@ -0,0 +1,47 @@ +--- +seo: + description: simpleXRPL is an opinionated TypeScript SDK that lets institutional developers express XRP Ledger operations as business intent and route them through the custodians they already use. +labels: + - simpleXRPL + - SDK +--- + +# simpleXRPL +[[Source]](https://github.com/ripple/simpleXRPL) + +`simpleXRPL` is an opinionated TypeScript SDK for the XRP Ledger, built for institutional developers who interact with the ledger through a custodian. It raises the level of your code from XRPL protocol mechanics to business operations that the SDK routes through your institutional custodians. Concretely, this means: + +- `simpleXRPL` defines the shape of business operations, handling the underlying XRPL transactions and custodian API calls. +- Your code doesn't change even if you switch custodians or operate across several at once. + +{% admonition type="warning" name="Caution" %} +`simpleXRPL` is pre-1.0. The public API may change between releases and no sandbox exists yet to test native custodian operations. +{% /admonition %} + + +## How It Works + +`simpleXRPL` is built around four concepts: + +- **Clients**: Establish the network connection and the connector configuration. Both are immutable for a client's lifetime; to change either, you create a new client. +- **Connectors**: Make up the execution model that determines *how* operations run and *who* holds account keys. Each connector exposes a uniform interface to the rest of the SDK, so the same code runs across all of them. +- **Accounts**: XRPL [accounts](https://xrpl.org/docs/concepts/accounts), each paired with the connector that signs for it. +- **Verticals**: Domain-specific classes and methods that group related business operations. + + +## Operation Execution + +For every operation, on every connector, `simpleXRPL` has a statically defined routing decision that it reports at initialization: + +- **Native**: Maps onto an endpoint a custodian exposes and natively handles. +- **Raw Signing**: For an operation the custodian exposes no native support for, the SDK builds the underlying XRPL transactions, the custodian signs the raw bytes, then the SDK submits them to the XRPL directly. Raw signing is off by default and enabled per connector; once on, it covers every operation that connector can't handle natively. +- **Unavailable**: The custodian doesn't expose a native endpoint and raw signing isn't enabled on the connector, so this operation is rejected. + +{% admonition type="info" name="Note" %} +For a complete list of supported operations by connector, see [Connector Routing](./references/connectors/connector-routing.md) +{% /admonition %} + + +## See Also + +- [Get Started](./get-started.md) diff --git a/docs/simpleXRPL/references/client.md b/docs/simpleXRPL/references/client.md new file mode 100644 index 00000000..bf99f282 --- /dev/null +++ b/docs/simpleXRPL/references/client.md @@ -0,0 +1,99 @@ +--- +seo: + description: The simpleXRPL client is the runtime entry point — SimpleXRPL.init() builds it, and it exposes the verticals, the discovered accounts, and the ledger connection lifecycle. +labels: + - simpleXRPL + - SDK +--- + +# Client + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/client/client.ts#L42) + +`SimpleXRPL.init()` is `simpleXRPL`'s entry point, and it resolves to a **`SimpleXRPLClient`** — the runtime client. The client binds your pre-constructed [connectors](./connectors/index.md) to a network, discovers the accounts they hold, and exposes the [verticals](./verticals/index.md) you call to build operations. Its network connection and connector configuration are fixed for its lifetime. + +A client constructed with no signers is still fully usable for reads; every write operation throws `NoSignerError` until a connector owns the target account. + + +## SimpleXRPL.init() + +Bind connectors to a network and discover their accounts. Resolves to a `SimpleXRPLClient`. + +### Signature + +```ts +SimpleXRPL.init(config: SimpleXRPLConfig): Promise +``` + +### Config + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `rippledUrl` | `string` | Yes | The rippled endpoint (`ws(s)://` or `http(s)://`). | +| `faucetUrl` | `string` | No | Faucet endpoint, used on test networks only. | +| `signers` | `array` | No | The pre-constructed connectors (a `Custodian[]`). Omit for a no-signer client that can still read the ledger; write verbs then throw `NoSignerError` until a signer is added. | +| `primarySigner` | `object` | No | The default connector for verbs called without an explicit account. Defaults to the first entry in `signers`. | +| `ledger` | `object` | No | Advanced: the ledger connection used for reads, autofill, and Local/raw submission. Defaults to a connection built from `rippledUrl`; inject a fake in tests. | + + +## SimpleXRPLClient + +### Properties + +Read-only members of the `SimpleXRPLClient` that `SimpleXRPL.init()` returns, set at construction. + +| Property | Type | Description | +| --- | --- | --- | +| `network` | `object` | The network the client is bound to — a `NetworkInfo` with `rippledUrl` (and `faucetUrl` on test networks). | +| `signers` | `array` | The registered connectors, 0 or more (a `Custodian[]`). | +| `primarySigner` | `object` | The default connector, used when a verb is called without an explicit account. `undefined` on a no-signer client. | +| `accounts` | `object` | Every discovered account as a read-only map keyed by r-address (`ReadonlyMap`). See [`Account`](types.md#account). | +| `ledger` | `object` | The shared ledger connection for reads, autofill, and Local/raw submission. Created lazily from `network.rippledUrl` when none was injected. | +| `intent` | `object` | Read-only inspector for custodian governance intents (status/await). | + + +### connect() + +Open the ledger connection. + +```ts +SimpleXRPLClient.connect(): Promise +``` + +### disconnect() + +Close the ledger connection and release its resources. + +```ts +SimpleXRPLClient.disconnect(): Promise +``` + +### refreshAccounts() + +Re-discover every connector's accounts and rebuild the account index. New accounts become addressable; accounts removed upstream are gone on the next lookup. Throws `AmbiguousAccountError` if an r-address is claimed by two connectors. + +```ts +SimpleXRPLClient.refreshAccounts(): Promise +``` + +### primaryAddress() + +The primary connector's account address, or `undefined` on a no-signer client. Reads default to this; it never throws, so queries work without a signer. + +```ts +SimpleXRPLClient.primaryAddress(): string | undefined +``` + + +## Example + +```ts +import { SimpleXRPL, LocalSigner } from 'simplexrpl' + +const client = await SimpleXRPL.init({ + rippledUrl: 'wss://s.altnet.rippletest.net:51233', // XRPL Testnet + signers: [LocalSigner.fromEnv()], +}) + +await client.disconnect() +``` diff --git a/docs/simpleXRPL/references/connectors/connector-routing.md b/docs/simpleXRPL/references/connectors/connector-routing.md new file mode 100644 index 00000000..62ce7130 --- /dev/null +++ b/docs/simpleXRPL/references/connectors/connector-routing.md @@ -0,0 +1,122 @@ +--- +seo: + description: The connector routing table — per XRPL transactor and per custodian, whether an operation routes native, requires the raw-signing fallback, or is unavailable. +labels: + - simpleXRPL + - SDK +--- + +# Connector Routing + +[[Source]](https://github.com/ripple/simpleXRPL/blob/main/docs/connector-routing.md) + +# Connector Routing Table + + + +How simpleXRPL dispatches each XRPL transactor per connector. Derived directly +from each custodian's native-operation set and the transactors the verticals +build, so it always matches the code. + +## Transactor → connector path + +The pipeline routes by transactor type: **Local** signs everything in-process; +a custodian uses its **native** operation when the transactor is in its +capability set, otherwise the **raw** sign-only fallback, otherwise the write +is rejected. + +| Transactor | Local | Ripple Custody | Palisade | +| ------ | ------ | ------ | ------ | +| `AccountSet` | signs locally | **native** | **native** | +| `Clawback` | signs locally | **native** | **native** | +| `CredentialAccept` | signs locally | raw fallback¹ | raw fallback¹ | +| `CredentialCreate` | signs locally | raw fallback¹ | raw fallback¹ | +| `CredentialDelete` | signs locally | raw fallback¹ | raw fallback¹ | +| `DepositPreauth` | signs locally | **native** | raw fallback¹ | +| `EscrowFinish` | signs locally | **native** | raw fallback¹ | +| `MPTokenAuthorize` | signs locally | **native** | raw fallback¹ | +| `MPTokenIssuanceCreate` | signs locally | **native** | raw fallback¹ | +| `MPTokenIssuanceDestroy` | signs locally | **native** | raw fallback¹ | +| `MPTokenIssuanceSet` | signs locally | **native** | raw fallback¹ | +| `OfferCancel` | signs locally | raw fallback¹ | **native** | +| `OfferCreate` | signs locally | **native** | **native** | +| `Payment` | signs locally | **native** | **native** | +| `PermissionedDomainDelete` | signs locally | raw fallback¹ | raw fallback¹ | +| `PermissionedDomainSet` | signs locally | raw fallback¹ | raw fallback¹ | +| `SetRegularKey` | signs locally | raw fallback¹ | raw fallback¹ | +| `TrustSet` | signs locally | **native** | **native** | + +¹ **raw fallback** applies only when raw signing is enabled on that custodian +(`allowRawSigning`). With raw signing disabled, a non-native transactor is +rejected with `SignerCapabilityError` — use a Local account or a custodian +that natively supports it. The raw path signs the encoded transaction and +submits it through the shared XRPL connection. + +## Vertical → transactors + +Which XRPL transactors each vertical builds. Cross-reference with the table +above to see how a given method routes on each connector. + +| Vertical | Transactors emitted | +| ------ | ------ | +| `account` | `AccountSet`, `DepositPreauth`, `Payment`, `SetRegularKey` | +| `credential` | `CredentialAccept`, `CredentialCreate`, `CredentialDelete` | +| `domain` | `PermissionedDomainDelete`, `PermissionedDomainSet` | +| `iou` | `AccountSet`, `Clawback`, `OfferCancel`, `OfferCreate`, `Payment`, `TrustSet` | +| `token` | `MPTokenAuthorize`, `MPTokenIssuanceCreate`, `MPTokenIssuanceDestroy`, `MPTokenIssuanceSet`, `OfferCancel`, `OfferCreate`, `Payment` | +| `xrp` | `Payment` | + +## Operation → native support + +Each simpleXRPL write operation, the XRPL transactor(s) it emits, and whether +that operation is **native** on each custodian (all its transactors are in the +custodian's native-ops set) or falls back to **raw** signing. Local signs every +operation in-process. Read operations emit no transactor and are omitted. + +| Operation | Transactor(s) | Ripple Custody | Palisade | +| ------ | ------ | ------ | ------ | +| `XRP.transfer()` | `Payment` | **native** | **native** | +| `IOU.issue()` | `TrustSet`, `AccountSet` | **native** | **native** | +| `IOU.authorize()` | `TrustSet` | **native** | **native** | +| `IOU.lock()` | `TrustSet` | **native** | **native** | +| `IOU.unlock()` | `TrustSet` | **native** | **native** | +| `IOU.clawback()` | `Clawback` | **native** | **native** | +| `IOU.transfer()` | `Payment` | **native** | **native** | +| `IOU.buyOffer()` | `OfferCreate` | **native** | **native** | +| `IOU.sellOffer()` | `OfferCreate` | **native** | **native** | +| `IOU.cancelOffer()` | `OfferCancel` | raw fallback¹ | **native** | +| `Token.issue()` | `MPTokenIssuanceCreate` | **native** | raw fallback¹ | +| `Token.authorize()` | `MPTokenAuthorize` | **native** | raw fallback¹ | +| `Token.unauthorize()` | `MPTokenAuthorize` | **native** | raw fallback¹ | +| `Token.grantHolder()` | `MPTokenAuthorize` | **native** | raw fallback¹ | +| `Token.revokeHolder()` | `MPTokenAuthorize` | **native** | raw fallback¹ | +| `Token.lock()` | `MPTokenIssuanceSet` | **native** | raw fallback¹ | +| `Token.unlock()` | `MPTokenIssuanceSet` | **native** | raw fallback¹ | +| `Token.destroy()` | `MPTokenIssuanceDestroy` | **native** | raw fallback¹ | +| `Token.transfer()` | `Payment` | **native** | raw fallback¹ | +| `Token.createOffer()` | `OfferCreate` | **native** | **native** | +| `Token.cancelOffer()` | `OfferCancel` | raw fallback¹ | **native** | +| `Domain.create()` | `PermissionedDomainSet` | raw fallback¹ | raw fallback¹ | +| `Domain.setCredentials()` | `PermissionedDomainSet` | raw fallback¹ | raw fallback¹ | +| `Domain.delete()` | `PermissionedDomainDelete` | raw fallback¹ | raw fallback¹ | +| `Credential.issue()` | `CredentialCreate` | raw fallback¹ | raw fallback¹ | +| `Credential.accept()` | `CredentialAccept` | raw fallback¹ | raw fallback¹ | +| `Credential.delete()` | `CredentialDelete` | raw fallback¹ | raw fallback¹ | +| `Account.fund()` | `Payment`, `AccountSet` | **native** | **native** | +| `Account.activate()` | `Payment`, `AccountSet` | **native** | **native** | +| `Account.set()` | `AccountSet` | **native** | **native** | +| `Account.setRegularKey()` | `SetRegularKey` | raw fallback¹ | raw fallback¹ | +| `Account.depositPreauth()` | `DepositPreauth` | **native** | raw fallback¹ | + +¹ **raw fallback** applies only when raw signing is enabled on that custodian +(`allowRawSigning`); otherwise the operation is rejected with +`SignerCapabilityError`. A multi-transactor operation (e.g. `IOU.issue`) is +native only when every step is native. **Palisade has no native MPT support**, +so `Token.transfer` — which carries an MPT amount — falls back to raw there +even though `Payment` is otherwise native; Ripple Custody handles MPT natively. + +--- + +_Native-ops sets: `NATIVE_XRPL_TRANSACTORS` (Ripple Custody), +`PALISADE_NATIVE_TRANSACTORS` (Palisade). Local signs all transactors._ diff --git a/docs/simpleXRPL/references/connectors/external.md b/docs/simpleXRPL/references/connectors/external.md new file mode 100644 index 00000000..5d61814f --- /dev/null +++ b/docs/simpleXRPL/references/connectors/external.md @@ -0,0 +1,94 @@ +--- +seo: + description: ExternalSigner is simpleXRPL's connector for keys held in a KMS or HSM. It signs through a caller-supplied port so the private key never enters the process. +labels: + - simpleXRPL + - SDK +--- + +# External + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/custodians/external/external-signer.ts#L40) + +An external connector signs with a key held by a KMS (AWS, GCP) or an HSM (PKCS#11, CloudHSM). The SDK owns the rest of the business operation lifecycle. + +`simpleXRPL` ships an AWS KMS adapter; for any other provider you must implement the port yourself. + + +## ExternalSigner.create() + +Fetches the signer's public key and resolves the account it acts as. + +### Signature + +```ts +ExternalSigner.create(options: ExternalSignerOptions): Promise +``` + +### Options + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `signer` | `object` | Yes | The KMS/HSM-backed signer for one key. Implements [ExternalSignerPort](#externalsignerport). | +| `address` | `string` | No | The XRPL address to act as. Defaults to the address derived from the signer's public key. | + + +## ExternalSignerPort + +The signing seam to implement, defined by the `algorithm` field. + +### Secp256k1SignerPort + +For secp256k1 keys (e.g., AWS KMS, most PKCS#11 HSMs). + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `algorithm` | `string` | Yes | Must be `secp256k1`. | +| `publicKey` | `function` | Yes | An async function, no arguments, returning the public key as an XRPL-format compressed hex string (33 bytes, `02`/`03` prefix). Signature: `() => Promise`. | +| `signDigest` | `function` | Yes | An async function that takes a 32-byte digest (XRPL's SHA-512Half of the signing data, as a byte array) and returns the raw signature scalars — an object `{ r, s }` where each is a `bigint`. The SDK normalizes to low-S and DER-encodes before attaching the signature. Signature: `(digest: Uint8Array) => Promise<{ r: bigint, s: bigint }>`. | + +### Ed25519SignerPort + +For ed25519 keys (e.g., GCP KMS, some HSMs). + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `algorithm` | `string` | Yes | Must be `ed25519`. | +| `publicKey` | `function` | Yes | An async function, no arguments, returning the public key as an XRPL-format hex string (33 bytes: the `ED` prefix followed by the 32-byte raw key). Signature: `() => Promise`. | +| `signMessage` | `function` | Yes | An async function that takes the message bytes (a byte array) and returns the raw 64-byte signature (a byte array). ed25519 hashes internally, so there is no pre-digest and no low-S step. Signature: `(message: Uint8Array) => Promise`. | + + +## AWS KMS adapter + +`simpleXRPL` ships a secp256k1 port for AWS KMS, imported from the `simplexrpl/aws-kms` subpath. It requires the peer dependency `@aws-sdk/client-kms` and an `ECC_SECG_P256K1` (secp256k1) KMS key. Credentials come from the standard AWS chain. + +### Signature + +```ts +AwsKmsSigner.create(options: AwsKmsSignerOptions): AwsKmsSigner +``` + +### Options + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `keyId` | `string` | Yes | The KMS key id or ARN. Must be an `ECC_SECG_P256K1` (secp256k1) key. | +| `client` | `object` | No | A pre-built AWS KMS client — a `KMSClient` from `@aws-sdk/client-kms`. Provide this, or `region` to construct the default. | +| `region` | `string` | No | AWS region, used to construct the default client when `client` is omitted. | + + +## Example + +```ts +// Sign with a key held in AWS KMS — the private key never leaves KMS. +import { AwsKmsSigner } from 'simplexrpl/aws-kms' +import { ExternalSigner } from 'simplexrpl' + +const signer = AwsKmsSigner.create({ + keyId: process.env.AWS_KMS_KEY_ID ?? '', + region: process.env.AWS_REGION ?? 'us-east-1', +}) + +// The XRPL account is derived from the key's public key. +const external = await ExternalSigner.create({ signer }) +``` diff --git a/docs/simpleXRPL/references/connectors/index.md b/docs/simpleXRPL/references/connectors/index.md new file mode 100644 index 00000000..dba6b10d --- /dev/null +++ b/docs/simpleXRPL/references/connectors/index.md @@ -0,0 +1,58 @@ +--- +seo: + description: A connector is a signing backend in simpleXRPL — LocalSigner, ExternalSigner, RippleCustody, or PalisadeCustody — constructed on its own and bound to the client at initialization. +labels: + - simpleXRPL + - SDK +--- + +# Connectors + +A connector is a signing backend: it determines how an operation runs and which custodian holds your account keys. Each is constructed and authenticated on its own, then passed to the client constructed by `simpleXRPL` in a `signers` array. `simpleXRPL` supports these connectors: + +- [Local](./local.md) +- [External](./external.md) +- [Ripple Custody](./ripple-custody.md) +- [Palisade](./palisade.md) + +Every connector implements the `Custodian` interface. Once constructed, it exposes these fields and methods: + + +## Fields + +| Field | Type | Description | +| --- | --- | --- | +| `kind` | `string` | The backend the connector adapts: `local`, `ripple-custody`, `palisade-custody`, or `external`. | +| `primary` | `object` | The connector's primary account reference. Used when a vertical operation runs without an explicit account. | +| `primary.address` | `string` | The primary account's XRPL r-address. | +| `primary.custodianRef` | `string` or `object`| _(Optional)_ The connector's opaque native id for the account. A `string` for account-id connectors, or a `{vaultId, walletId}` object for vault-based connectors. Absent for local wallets. | + + +## Methods + +### listAccounts() + +List the accounts the connector holds. + +#### Signature + +```ts +connector.listAccounts(): Promise +``` + +#### Parameters + +`listAccounts` takes no arguments. + +#### Returns + +Resolves to an array of [Account](../types.md#account) records the connector discovered and can sign for. + +#### Example + +```ts +const accounts = await connector.listAccounts() + +console.log(accounts.map((account) => account.address)) +``` + diff --git a/docs/simpleXRPL/references/connectors/local.md b/docs/simpleXRPL/references/connectors/local.md new file mode 100644 index 00000000..de2e70f6 --- /dev/null +++ b/docs/simpleXRPL/references/connectors/local.md @@ -0,0 +1,73 @@ +--- +seo: + description: LocalSigner is simpleXRPL's self-custody connector — it holds xrpl wallets in-process and signs locally, for development and testing. +labels: + - simpleXRPL + - SDK +--- + +# Local + + [[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/custodians/local/local-signer.ts#L22) + +A local connector holds one or more XRPL accounts in-process and signs operations locally. This connector is intended for development and testing purposes. Since this method doesn't require external authentication, it is constructed synchornously unlike other connectors. + +## LocalSigner.fromEnv() + +Builds one wallet per `XRPL_*_SEED` environment variable (matching `XRPL__SEED` and a plain `XRPL_SEED`). The primary defaults to the first seed found. + +### Signature + +```ts +LocalSigner.fromEnv(options?: LocalSignerFromEnvOptions): LocalSigner +``` + +### Options + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `primary` | `string` | No | The primary account's r-address. Defaults to the first seed in scan order. | +| `env` | `Record` | No | Environment source to scan — a map of variable names to values. Defaults to `process.env`. | + + +## LocalSigner.fromSeed() + +Builds a single wallet from a seed string. + +### Signature + +```ts +LocalSigner.fromSeed(seed: string): LocalSigner +``` + +### Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `seed` | `string` | Yes | The wallet seed (the caller's responsibility to source). | + + +## LocalSigner.create() + +Builds from pre-constructed `xrpl` `Wallet` objects. + +### Signature + +```ts +LocalSigner.create(options: LocalSignerCreateOptions): LocalSigner +``` + +### Options + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `wallets` | `readonly Wallet[]` | Yes | The xrpl `Wallet` objects this signer holds (at least one), e.g. `[Wallet.fromSeed(seed)]`. | +| `primary` | `string` | No | The primary account's r-address. Defaults to the first wallet. | + + +## Example + +```ts +// One wallet per XRPL_*_SEED in the environment. +const local = LocalSigner.fromEnv() +``` diff --git a/docs/simpleXRPL/references/connectors/palisade.md b/docs/simpleXRPL/references/connectors/palisade.md new file mode 100644 index 00000000..952949ed --- /dev/null +++ b/docs/simpleXRPL/references/connectors/palisade.md @@ -0,0 +1,54 @@ +--- +seo: + description: PalisadeCustody is simpleXRPL's production connector for Palisade — construction config and required fields for create(). +labels: + - simpleXRPL + - SDK +--- + +# Palisade + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/custodians/palisade/config.ts#L10) + +Palisade is a Wallet-as-a-Service. This connector authenticates via OAuth2 client credentials and acts on specific vaults/wallets. See: [Getting started with the API](https://docs.ripple.com/products/wallet/getting-started/getting-started-api) for instructions on creating API credentials to fill in this constructor. + + +## PalisadeCustody.create() + +Exchanges the credentials and discovers the org's wallets. + +### Signature + +```ts +PalisadeCustody.create(config: PalisadeCustodyConfig): Promise +``` + +### Config + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `baseUrl` | `string` | Yes | Palisade API base URL (must be HTTPS). | +| `clientId` | `string` | Yes | OAuth2 client-credentials id. | +| `clientSecret` | `string` | Yes | OAuth2 client-credentials secret (held in memory only). | +| `primary` | `PalisadeWalletRef` | Yes | The wallet used when a verb is called without an explicit account. | +| `primary.vaultId` | `string` | Yes | The primary wallet's vault id. | +| `primary.walletId` | `string` | Yes | The primary wallet's id. | +| `allowRawSigning` | `boolean` | No | Allow the raw fallback for transactors/fields Palisade can't map. Defaults to `false`. | +| `defaultTimeoutMs` | `number` | No | How long to wait for a native submission to reach a terminal status. | +| `http` | `object` | No | A custom HTTP transport (implements `PalisadeHttpPort`). Defaults to the production fetch port; most callers omit it. | +| `now` | `() => number` | No | Injectable clock for the auth service, returning epoch ms, e.g. `() => Date.now()`. Defaults to `Date.now`. | + + +## Example + +```ts +const palisade = await PalisadeCustody.create({ + baseUrl: 'https://api.sandbox.palisade.co', + clientId: process.env.PALISADE_CLIENT_ID ?? '', + clientSecret: process.env.PALISADE_CLIENT_SECRET ?? '', + primary: { + vaultId: process.env.PALISADE_VAULT_ID ?? '', + walletId: process.env.PALISADE_WALLET_ID ?? '', + }, +}) +``` diff --git a/docs/simpleXRPL/references/connectors/ripple-custody.md b/docs/simpleXRPL/references/connectors/ripple-custody.md new file mode 100644 index 00000000..03974541 --- /dev/null +++ b/docs/simpleXRPL/references/connectors/ripple-custody.md @@ -0,0 +1,82 @@ +--- +seo: + description: RippleCustody is simpleXRPL's production connector for Ripple Custody — construction options and required fields for create() and fromEnv(). +labels: + - simpleXRPL + - SDK +--- + +# Ripple Custody + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/custodians/ripple/construction.ts#L30) + +Ripple Custody authenticates with an intent-author key exchanged for a token. A Custody deployment is per-tenant, so its gateway and token URLs point at the instance provisioned for you. See: [Generate a key pair and register a public key](https://docs.ripple.com/products/custody/identity-and-access/authentication/generate-api-keys-and-register) for instructions on creating API credentials to fill in this constructor. + + +## RippleCustody.create() + +Construct with every value passed explicitly. + +### Signature + +```ts +RippleCustody.create(options: RippleCustodyOptions): Promise +``` + +### Options + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `gatewayUrl` | `string` | Yes | The Custody gateway base URL. | +| `auth` | `RippleCustodyAuthOptions` | Yes | Intent-author credentials and token endpoint. | +| `auth.signingKey` | `string` | Yes | Intent-author private key: PEM contents, or a path to a `.pem` file. | +| `auth.tokenUrl` | `string` | Yes | The Custody token endpoint URL. | +| `auth.publicKey` | `string` | No | Matching public key, base64 SPKI DER. Derived from `signingKey` if omitted. | +| `domainId` | `string` | Yes | The Custody domain this custodian operates in. | +| `primary` | `string` | Yes | The primary account's r-address; validated against the discovered set. | +| `allowRawSigning` | `boolean` | No | Enable the raw-signing fallback. Defaults to `false`. | +| `defaultFee` | `FeeIntent` | No | Fee tier: `{ priority?: 'low' \| 'medium' \| 'high' }`. Backends that can't honor the tier auto-price and warn. Defaults to `low`. | +| `defaultDryRun` | `boolean` | No | Pre-flight every write through Custody's dry-run. Defaults to `false`. | +| `defaultTimeoutMs` | `number` | No | How long `submitAndWait` polls before throwing `IntentPendingError`. | +| `http` | `CustodyHttpPort` | No | Advanced: a custom HTTP transport, shape `{ send: (request) => Promise }`. Defaults to the production fetch port; most callers omit it. | + + +## RippleCustody.fromEnv() + +Reads the endpoints, credentials, and domain from environment variables. + +### Signature + +```ts +RippleCustody.fromEnv(options: RippleCustodyFromEnvOptions): Promise +``` + +### Options + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `primary` | `string` | Yes | The primary account's r-address; validated against the discovered set. | +| `allowRawSigning` | `boolean` | No | Enable the raw-signing fallback. Defaults to `false`. | +| `defaultFee` | `FeeIntent` | No | Fee tier: `{ priority?: 'low' \| 'medium' \| 'high' }`. Backends that can't honor the tier auto-price and warn. Defaults to `low`. | +| `defaultDryRun` | `boolean` | No | Pre-flight every write through Custody's dry-run. Defaults to `false`. | +| `defaultTimeoutMs` | `number` | No | How long `submitAndWait` polls before throwing `IntentPendingError`. | +| `env` | `object` | No | The source the `RIPPLE_CUSTODY_*` environment variables are read from, as a map of names to values. Defaults to `process.env`. | +| `http` | `object` | No | A custom HTTP transport (implements `CustodyHttpPort`). Defaults to the production fetch port; most callers omit it. | + +{% admonition type="info" name="Note" %} +`env` requires these keys: +- `RIPPLE_CUSTODY_GATEWAY_URL` +- `RIPPLE_CUSTODY_AUTH_SIGNING_KEY` +- `RIPPLE_CUSTODY_AUTH_TOKEN_URL` +- `RIPPLE_CUSTODY_AUTH_PUBLIC_KEY` (optional) +- `RIPPLE_CUSTODY_DOMAIN_ID` +{% /admonition %} + + +## Example + +```ts +const rippleCustody = await RippleCustody.fromEnv({ + primary: process.env.RIPPLE_CUSTODY_PRIMARY ?? '', +}) +``` diff --git a/docs/simpleXRPL/references/errors.md b/docs/simpleXRPL/references/errors.md new file mode 100644 index 00000000..5335cbc2 --- /dev/null +++ b/docs/simpleXRPL/references/errors.md @@ -0,0 +1,30 @@ +--- +seo: + description: The simpleXRPL client errors. +labels: + - simpleXRPL + - SDK +--- + +# Errors + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/errors.ts#L8) + +All errors extend `SimpleXRPLError`, so you can catch the base class or narrow to a specific type. + +| Error | Description | +| --- | --- | +| `SimpleXRPLError` | Base class for every SDK error. | +| `NoSignerError` | No signer/connector owns the target account. | +| `SignerCapabilityError` | The operation can't be signed on this connector (native path missing, or raw signing not enabled). | +| `AccountNotFoundError` | The referenced account is not bound to the client. | +| `AmbiguousAccountError` | The account reference matches more than one bound account. | +| `DuplicateSignerError` | Two signers target the same backend tenant (same kind and tenant id); rejected at `init`. | +| `RippledSubmitError` | The transaction reached a terminal on-ledger failure (non-`tesSUCCESS`). | +| `IntentPendingError` | A custodian intent is still awaiting approval when a terminal result was expected. | +| `IntentValidationError` | A custodian rejected the intent as invalid. | +| `MultiStepFailureError` | A multi-step operation failed partway through. | +| `CustodyAuthError` | Authenticating with Ripple Custody failed (challenge/JWT exchange or refresh). | +| `CustodyApiError` | A Ripple Custody API call returned an error (HTTP status, `hint`, and raw body preserved). | +| `PalisadeAuthError` | Authenticating with Palisade failed (API key). | +| `PalisadeApiError` | A Palisade API call returned an error (HTTP status, `hint`, and raw body preserved). | diff --git a/docs/simpleXRPL/references/types.md b/docs/simpleXRPL/references/types.md new file mode 100644 index 00000000..9d4fba20 --- /dev/null +++ b/docs/simpleXRPL/references/types.md @@ -0,0 +1,50 @@ +--- +seo: + description: Core types in simpleXRPL — the shared account records (Account, AccountRef) and the account selector used across the client, connectors, and verticals. +labels: + - simpleXRPL + - SDK +--- + +# Core Types + +Core types are the shared records the SDK uses across the client, connectors, and verticals — as opposed to the parameters and results specific to a single operation. They describe how simpleXRPL identifies and references XRPL accounts. + +## Account + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/domain/model.ts#L41) + +A discovered account: its r-address paired with the connector that owns and signs for it. The SDK hands you an `Account` from `client.accounts` and [`connector.listAccounts()`](connectors/index.md). It extends [`AccountRef`](#accountref). + +This is distinct from `AccountData`, the on-chain snapshot returned by [`account.retrieve`](verticals/account/retrieve.md). + +| Field | Type | Description | +| --- | --- | --- | +| `address` | `string` | The XRPL r-address — the canonical key the SDK uses to identify the account. | +| `signer` | `object` | The [connector](connectors/index.md) (a `Custodian`) that discovered and signs for this account. | +| `alias` | `string` _(optional)_ | A connector-side alias, when the backend exposes one. | +| `custodianRef` | `string` \| `object` _(optional)_ | The owning connector's opaque native id for the account — a `string` for account-id connectors, or a `{ vaultId, walletId }` object for vault-based connectors; absent for local wallets. | +| `metadata` | `object` _(optional)_ | Advisory-only. Shape `{ kind?, tags? }`, where `kind` is the connector kind (`'local'`, `'ripple-custody'`, `'palisade-custody'`, or `'external'`) and `tags` is a list of strings. | + +## AccountRef + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/domain/model.ts#L29) + +The minimal reference to an account — just its r-address and the owning connector's native id. [`Account`](#account) extends it, and a connector's `primary` field is an `AccountRef`. + +| Field | Type | Description | +| --- | --- | --- | +| `address` | `string` | The XRPL r-address. | +| `custodianRef` | `string` \| `object` _(optional)_ | The owning connector's opaque native id for the account — a `string` for account-id connectors, or a `{ vaultId, walletId }` object for vault-based connectors; absent for local wallets. | + +## AccountSelector + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/domain/model.ts#L59) + +How you choose the source account for a verb — the `from` option on write operations. It is one of three forms: + +| Form | Type | Description | +| --- | --- | --- | +| r-address | `string` | A bare r-address string. | +| `{ address }` | `object` | An object holding an explicit r-address. | +| `{ signer, account? }` | `object` | A connector, optionally narrowed to one of the accounts it owns (by r-address). | diff --git a/docs/simpleXRPL/references/verticals/account/activate.md b/docs/simpleXRPL/references/verticals/account/activate.md new file mode 100644 index 00000000..2d4503cf --- /dev/null +++ b/docs/simpleXRPL/references/verticals/account/activate.md @@ -0,0 +1,58 @@ +--- +seo: + description: Account.activate activates a created account by sending it XRP from the operator account, then enabling rippling. +labels: + - simpleXRPL + - SDK +--- + +# account.activate() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/account.ts#L151) + +Activate a created account by sending it XRP from the operator (primary) account, then enabling rippling. This is the any-network counterpart to [fund](fund.md). The account must be signable by this client (e.g., from [create](create.md)). + +## Signature + +```ts +account.activate( + params: AccountActivateParams, + options?: AccountWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `destination` | `string` | Yes | The r-address to activate (typically from `Account.create`). | +| `amount` | `string` | No | XRP to send. Defaults to the network's base reserve (plus a small buffer). | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult` (from the `defaultRipple` settings change). + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +`Account.activate` attaches no `intent` output; `intent` is `undefined`. + +## Underlying XRPL transactors + +Runs as an ordered, multi-step sequence: + +1. [Payment](https://xrpl.org/docs/references/protocol/transactions/types/payment) — the operator sends XRP to the destination. +2. [AccountSet](https://xrpl.org/docs/references/protocol/transactions/types/accountset) — the new account enables rippling (`defaultRipple`). + +## Example + +```ts +await client.account.activate({ + destination: 'rNewAccount...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/account/create.md b/docs/simpleXRPL/references/verticals/account/create.md new file mode 100644 index 00000000..3c683be2 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/account/create.md @@ -0,0 +1,52 @@ +--- +seo: + description: Account.create generates a new XRPL keypair locally and registers it. No transaction is submitted. +labels: + - simpleXRPL + - SDK +--- + +# account.create() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/account.ts#L72) + +Generate a new XRPL keypair locally and register it so it can be funded and used right away. Use this only to mint an additional account outside of `SimpleXRPL.init`. + +{% admonition type="warning" name="Warning" %} +Nothing is written to the ledger until the account is funded. The returned `seed` (and `privateKey`) are secret and are the only way to control the account. Store them securely and never log or transmit them. +{% /admonition %} + +## Signature + +```ts +account.create(): AccountCredentials +``` + +## Parameters + +None. `Account.create` takes no arguments. + +## Returns + +Returns an `AccountCredentials` object **synchronously**. This is the one `Account` operation that does not submit a transaction, so it does not return a `SubmissionResult`. + +### Return fields + +| Field | Type | Description | +| --- | --- | --- | +| `address` | `string` | The classic r-address. | +| `publicKey` | `string` | The public key (hex). | +| `privateKey` | `string` | The private key (hex) — sensitive. | +| `seed` | `string` | The account seed (secret) — sensitive. | + +## Underlying XRPL transactor + +None. `Account.create` generates a keypair locally and writes nothing to the ledger. Use [activate](activate.md) or [fund](fund.md) to bring the account on-ledger. + +## Example + +```ts +const { address, seed } = client.account.create() + +console.log(address) +``` diff --git a/docs/simpleXRPL/references/verticals/account/depositPreauth.md b/docs/simpleXRPL/references/verticals/account/depositPreauth.md new file mode 100644 index 00000000..31dab991 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/account/depositPreauth.md @@ -0,0 +1,55 @@ +--- +seo: + description: Account.depositPreauth grants or revokes deposit preauthorization for another account via a DepositPreauth transaction. +labels: + - simpleXRPL + - SDK +--- + +# account.depositPreauth() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/account.ts#L263) + +Grant or revoke deposit preauthorization for another account. + +## Signature + +```ts +account.depositPreauth( + params: DepositPreauthParams, + options?: AccountWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `authorize` | `string` | No | An r-address to preauthorize for deposits. | +| `unauthorize` | `string` | No | An r-address to remove preauthorization from. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +`Account.depositPreauth` attaches no `intent` output; `intent` is `undefined`. + +## Underlying XRPL transactor + +Builds and submits a single [DepositPreauth](https://xrpl.org/docs/references/protocol/transactions/types/depositpreauth) transaction. + +## Example + +```ts +await client.account.depositPreauth({ + authorize: 'rTrusted...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/account/fund.md b/docs/simpleXRPL/references/verticals/account/fund.md new file mode 100644 index 00000000..69b5b1c7 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/account/fund.md @@ -0,0 +1,58 @@ +--- +seo: + description: Account.fund funds a created account from a testnet/devnet faucet, then enables rippling via an AccountSet transaction. +labels: + - simpleXRPL + - SDK +--- + +# account.fund() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/account.ts#L124) + +Fund a created account via the network faucet (Testnet/Devnet), then enable [rippling](https://xrpl.org/docs/concepts/tokens/fungible-tokens/rippling). The account must be one this client can sign for (e.g. from [create](create.md)). + +{% admonition type="info" name="Note" %} +`fund` requires a faucet-capable ledger (Testnet/Devnet). On other networks it throws an error, so use [activate](activate.md) to fund from an operator account instead. +{% /admonition %} + +## Signature + +```ts +account.fund( + params: AccountFundParams, + options?: AccountWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `destination` | `string` | Yes | The r-address to fund (typically from `Account.create`). | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult` (from the `defaultRipple` settings change). + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +`Account.fund` attaches no `intent` output; `intent` is `undefined`. + +## Underlying XRPL transactor + +Funds the account via the network faucet (an off-ledger request, not a submitted transaction), then builds and submits a single [AccountSet](https://xrpl.org/docs/references/protocol/transactions/types/accountset) transaction to enable rippling (`defaultRipple`). + +## Example + +```ts +await client.account.fund({ + destination: 'rNewAccount...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/account/index.md b/docs/simpleXRPL/references/verticals/account/index.md new file mode 100644 index 00000000..35817433 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/account/index.md @@ -0,0 +1,22 @@ +--- +seo: + description: The Account vertical in simpleXRPL manages account creation, funding, settings, regular keys, and deposit preauthorization. +labels: + - simpleXRPL + - SDK +--- + +# Account + +The `Account` vertical handles account creation, funding, and administration. (The class is named `AccountVertical` to avoid colliding with the [`Account`](../../types.md#account) record type — a [core type](../../types.md) used across the SDK; it is reached as `client.account`.) + +| Method | Description | +| --- | --- | +| [create](create.md) | Generate a new keypair locally (no transaction). | +| [activate](activate.md) | Activate a created account with operator-funded XRP. | +| [fund](fund.md) | Fund a created account from a testnet/devnet faucet. | +| [set](set.md) | Update account settings and flags. | +| [setRegularKey](setRegularKey.md) | Set or remove the account's regular key. | +| [depositPreauth](depositPreauth.md) | Grant or revoke deposit preauthorization. | +| [retrieve](retrieve.md) | Read an account's on-chain state. | +| [listOffers](listOffers.md) | List the DEX offers placed by an account. | diff --git a/docs/simpleXRPL/references/verticals/account/listOffers.md b/docs/simpleXRPL/references/verticals/account/listOffers.md new file mode 100644 index 00000000..2ecb449f --- /dev/null +++ b/docs/simpleXRPL/references/verticals/account/listOffers.md @@ -0,0 +1,49 @@ +--- +seo: + description: Account.listOffers lists the open DEX offers placed by an account. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# account.listOffers() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/account.ts#L105) + +List the open DEX offers placed by an account. + +## Signature + +```ts +account.listOffers( + params?: AccountListOffersParams, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `account` | `string` | No | The account whose offers to list. Defaults to the primary signer's account. | + +## Returns + +Resolves to a `ListOffersResult`: + +| Field | Type | Description | +| --- | --- | --- | +| `data` | `readonly OfferSummary[]` | The shaped open offers. See [token.listOffers](../token/listOffers.md#offersummary) for `OfferSummary`. | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [account_offers](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/account-methods/account_offers). + +## Example + +```ts +const { data } = await client.account.listOffers() + +for (const offer of data) { + console.log(offer.offerSequence, offer.type, offer.amount) +} +``` diff --git a/docs/simpleXRPL/references/verticals/account/retrieve.md b/docs/simpleXRPL/references/verticals/account/retrieve.md new file mode 100644 index 00000000..f793ba57 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/account/retrieve.md @@ -0,0 +1,57 @@ +--- +seo: + description: Account.retrieve reads an account's on-chain state — balance, sequence, owner count, and flags. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# account.retrieve() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/account.ts#L93) + +Read an account's on-chain state — XRP balance, sequence, owner count, and flags. + +## Signature + +```ts +account.retrieve( + params?: AccountRetrieveParams, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `account` | `string` | No | The account to read. Defaults to the primary signer's account. | + +## Returns + +Resolves to an `AccountRetrieveResult`: + +| Field | Type | Description | +| --- | --- | --- | +| `data` | `AccountData` | The point-in-time account snapshot. | + +### AccountData + +| Field | Type | Description | +| --- | --- | --- | +| `address` | `string` | The account's r-address. | +| `xrpBalance` | `string` | The XRP balance (converted from drops). | +| `sequence` | `number` | The account sequence number. | +| `ownerCount` | `number` | The number of owned ledger objects (drives the reserve). | +| `flags` | `Readonly>` | Account flags as booleans, as reported by `account_flags`. | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [account_info](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/account-methods/account_info) (flags are resolved via `account_flags`). + +## Example + +```ts +const { data } = await client.account.retrieve() + +console.log(data.xrpBalance) +``` diff --git a/docs/simpleXRPL/references/verticals/account/set.md b/docs/simpleXRPL/references/verticals/account/set.md new file mode 100644 index 00000000..e30ae286 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/account/set.md @@ -0,0 +1,71 @@ +--- +seo: + description: Account.set updates account settings and flags via an AccountSet transaction. +labels: + - simpleXRPL + - SDK +--- + +# account.set() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/account.ts#L190) + +Update account settings. Flags are named booleans (`true` enables, `false` disables); `transferRate`, `tickSize`, and `domain` are set directly. At least one parameter is required. + +{% admonition type="info" name="Note" %} +A single `AccountSet` enables at most one flag and disables at most one. Toggling more than one flag in the same direction is rejected. Call `set()` once per such change. +{% /admonition %} + +## Signature + +```ts +account.set( + params: AccountSetParams, + options?: AccountWriteOptions, +): Promise> +``` + +## Parameters + +All parameters are optional individually, but at least one must be provided. + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `noFreeze` | `boolean` | No | Permanently give up the ability to freeze trust lines (irreversible). | +| `clawbackEnabled` | `boolean` | No | Permanently allow this issuer to claw back issued tokens (irreversible). | +| `trustLineLocking` | `boolean` | No | Permanently allow trust line locking (irreversible). | +| `disableMaster` | `boolean` | No | Permanently disable the master key pair (irreversible). | +| `requireAuth` | `boolean` | No | Require holders to be authorized before they can hold issued tokens. | +| `requireDest` | `boolean` | No | Require a destination tag on incoming payments. | +| `defaultRipple` | `boolean` | No | Enable rippling on trust lines by default. | +| `globalFreeze` | `boolean` | No | Freeze all trust lines issued by this account. | +| `disallowXRP` | `boolean` | No | Disallow incoming XRP payments (advisory). | +| `transferRate` | `number` | No | Transfer fee for issued currencies, as a percentage (`0.5` = 0.5%, range 0–100). | +| `tickSize` | `number` | No | Tick size for offers (3–15, or `0` to disable). | +| `domain` | `string` | No | The account domain, as a plain string (hex-encoded on the ledger). | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +`Account.set` attaches no `intent` output; `intent` is `undefined`. + +## Underlying XRPL transactor + +Builds and submits a single [AccountSet](https://xrpl.org/docs/references/protocol/transactions/types/accountset) transaction. + +## Example + +```ts +await client.account.set({ + requireAuth: true, +}) +``` diff --git a/docs/simpleXRPL/references/verticals/account/setRegularKey.md b/docs/simpleXRPL/references/verticals/account/setRegularKey.md new file mode 100644 index 00000000..7ae8f584 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/account/setRegularKey.md @@ -0,0 +1,54 @@ +--- +seo: + description: Account.setRegularKey sets or removes the account's regular key via a SetRegularKey transaction. +labels: + - simpleXRPL + - SDK +--- + +# account.setRegularKey() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/account.ts#L235) + +Set or remove the account's regular key. + +## Signature + +```ts +account.setRegularKey( + params: SetRegularKeyParams = {}, + options?: AccountWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `regularKey` | `string` | No | The regular key r-address to set. Omit to remove the current regular key. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +`Account.setRegularKey` attaches no `intent` output; `intent` is `undefined`. + +## Underlying XRPL transactor + +Builds and submits a single [SetRegularKey](https://xrpl.org/docs/references/protocol/transactions/types/setregularkey) transaction. + +## Example + +```ts +await client.account.setRegularKey({ + regularKey: 'rRegularKey...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/credential/accept.md b/docs/simpleXRPL/references/verticals/credential/accept.md new file mode 100644 index 00000000..09c6cc5b --- /dev/null +++ b/docs/simpleXRPL/references/verticals/credential/accept.md @@ -0,0 +1,61 @@ +--- +seo: + description: Credential.accept accepts a credential issued to the calling account via a CredentialAccept transaction. +labels: + - simpleXRPL + - SDK +--- + +# credential.accept() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/credential.ts#L103) + +Accept a credential issued to the calling account. The calling account is the holder. + +## Signature + +```ts +credential.accept( + params: CredentialAcceptParams, + options?: CredentialWriteOptions, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `credType` | `string` | Yes | The credential type, as a plain string (hex-encoded on the ledger). | +| `issuer` | `string` | Yes | The issuer r-address. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult<{ issuer: string; credType: string }>`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Credential.accept`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `issuer` | `string` | The issuer r-address of the accepted credential. | +| `credType` | `string` | The credential type that was accepted. | + +## Underlying XRPL transactor + +Builds and submits a single [CredentialAccept](https://xrpl.org/docs/references/protocol/transactions/types/credentialaccept) transaction. + +## Example + +```ts +await client.credential.accept({ + credType: 'KYC', + issuer: 'rIssuer...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/credential/delete.md b/docs/simpleXRPL/references/verticals/credential/delete.md new file mode 100644 index 00000000..6c6d3567 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/credential/delete.md @@ -0,0 +1,61 @@ +--- +seo: + description: Credential.delete deletes an on-ledger credential, as either its issuer or its holder, via a CredentialDelete transaction. +labels: + - simpleXRPL + - SDK +--- + +# credential.delete() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/credential.ts#L133) + +Delete a credential, as either its issuer or its holder. + +## Signature + +```ts +credential.delete( + params: CredentialDeleteParams, + options?: CredentialWriteOptions, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `credType` | `string` | Yes | The credential type, as a plain string (hex-encoded on the ledger). | +| `holder` | `string` | No | The holder r-address. Set this when deleting as the issuer. | +| `issuer` | `string` | No | The issuer r-address. Set this when deleting as the holder. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult<{ credType: string }>`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Credential.delete`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `credType` | `string` | The credential type that was deleted. | + +## Underlying XRPL transactor + +Builds and submits a single [CredentialDelete](https://xrpl.org/docs/references/protocol/transactions/types/credentialdelete) transaction. + +## Example + +```ts +await client.credential.delete({ + credType: 'KYC', + issuer: 'rIssuer...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/credential/index.md b/docs/simpleXRPL/references/verticals/credential/index.md new file mode 100644 index 00000000..3def6c1c --- /dev/null +++ b/docs/simpleXRPL/references/verticals/credential/index.md @@ -0,0 +1,19 @@ +--- +seo: + description: The Credential vertical in simpleXRPL issues, accepts, and deletes on-ledger credentials. +labels: + - simpleXRPL + - SDK +--- + +# Credential + +The `Credential` vertical issues, accepts, and deletes on-ledger [credentials](https://xrpl.org/docs/concepts/decentralized-storage/credentials). + +| Method | Description | +| --- | --- | +| [issue](issue.md) | Issue a credential to a destination account. | +| [accept](accept.md) | Accept a credential issued to the calling account. | +| [delete](delete.md) | Delete a credential, as either its issuer or its holder. | +| [retrieve](retrieve.md) | Read a single credential. | +| [list](list.md) | List the credentials an account holds or issued. | diff --git a/docs/simpleXRPL/references/verticals/credential/issue.md b/docs/simpleXRPL/references/verticals/credential/issue.md new file mode 100644 index 00000000..92f34027 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/credential/issue.md @@ -0,0 +1,63 @@ +--- +seo: + description: Credential.issue issues an on-ledger credential to a destination account via a CredentialCreate transaction. +labels: + - simpleXRPL + - SDK +--- + +# credential.issue() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/credential.ts#L67) + +Issue a credential to a destination account. The calling account is the issuer. + +## Signature + +```ts +credential.issue( + params: CredentialIssueParams, + options?: CredentialWriteOptions, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `destination` | `string` | Yes | The destination (holder) r-address the credential is about. | +| `credType` | `string` | Yes | The credential type, as a plain string (hex-encoded on the ledger). | +| `expiration` | `number` | No | Expiration, in seconds since the Ripple epoch. | +| `URI` | `string` | No | An optional URI, as a plain string (hex-encoded on the ledger). | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult<{ destination: string; credType: string }>`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Credential.issue`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `destination` | `string` | The destination (holder) r-address the credential was issued to. | +| `credType` | `string` | The credential type that was issued. | + +## Underlying XRPL transactor + +Builds and submits a single [CredentialCreate](https://xrpl.org/docs/references/protocol/transactions/types/credentialcreate) transaction. + +## Example + +```ts +await client.credential.issue({ + destination: 'rHolder...', + credType: 'KYC', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/credential/list.md b/docs/simpleXRPL/references/verticals/credential/list.md new file mode 100644 index 00000000..5780ce17 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/credential/list.md @@ -0,0 +1,51 @@ +--- +seo: + description: Credential.list lists the credentials an account holds or issued. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# credential.list() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/credential.ts#L54) + +List credentials an account holds (default) or issued. + +## Signature + +```ts +credential.list( + params?: CredentialListParams, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `role` | `'holder' \| 'issuer'` | No | Query as `holder` (default) or `issuer`. | +| `account` | `string` | No | The account whose credentials to list. Defaults to the primary signer's account. | + +## Returns + +Resolves to a `CredentialListResult`, where `credentials[i]` corresponds to `data[i]`: + +| Field | Type | Description | +| --- | --- | --- | +| `credentials` | `readonly CredentialRef[]` | The identifier of each credential (`credType`, `issuer`, `holder`). | +| `data` | `readonly CredentialData[]` | The shaped credentials. See [credential.retrieve](retrieve.md#credentialdata) for `CredentialData`. | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [account_objects](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/account-methods/account_objects). + +## Example + +```ts +const { data } = await client.credential.list({ role: 'holder' }) + +for (const cred of data) { + console.log(cred.credType, cred.accepted) +} +``` diff --git a/docs/simpleXRPL/references/verticals/credential/retrieve.md b/docs/simpleXRPL/references/verticals/credential/retrieve.md new file mode 100644 index 00000000..1ec67565 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/credential/retrieve.md @@ -0,0 +1,66 @@ +--- +seo: + description: Credential.retrieve reads a single credential by type and issuer. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# credential.retrieve() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/credential.ts#L42) + +Retrieve a single credential by type and issuer (point-in-time). + +## Signature + +```ts +credential.retrieve( + params: CredentialRetrieveParams, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `credType` | `string` | Yes | The credential type. | +| `issuer` | `string` | Yes | The issuer r-address. | +| `account` | `string` | No | The holder (subject). Defaults to the primary signer's account. | + +## Returns + +Resolves to a `CredentialRetrieveResult`: + +| Field | Type | Description | +| --- | --- | --- | +| `credType` | `string` | The credential type. | +| `issuer` | `string` | The issuer r-address. | +| `holder` | `string` | The holder (subject) r-address. | +| `data` | `CredentialData \| undefined` | The credential snapshot, or `undefined` if none exists. | + +### CredentialData + +| Field | Type | Description | +| --- | --- | --- | +| `credType` | `string` | The credential type. | +| `issuer` | `string` | The issuer r-address. | +| `holder` | `string` | The holder (subject) r-address. | +| `accepted` | `boolean` | Whether the holder has accepted the credential. | +| `uri` | `string` _(optional)_ | The optional URI (decoded from hex). | +| `expiration` | `number` _(optional)_ | Expiration (seconds since the Ripple epoch), if set. | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [ledger_entry](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/ledger-methods/ledger_entry). + +## Example + +```ts +const { data } = await client.credential.retrieve({ + credType: 'KYC', + issuer: 'rIssuer...', +}) + +console.log(data?.accepted) +``` diff --git a/docs/simpleXRPL/references/verticals/domain/create.md b/docs/simpleXRPL/references/verticals/domain/create.md new file mode 100644 index 00000000..da402291 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/domain/create.md @@ -0,0 +1,67 @@ +--- +seo: + description: Domain.create creates a new permissioned domain via a PermissionedDomainSet transaction. +labels: + - simpleXRPL + - SDK +--- + +# domain.create() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/domain.ts#L70) + +Create a new permissioned domain. + +## Signature + +```ts +domain.create( + params: DomainCreateParams, + options?: DomainWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `credList` | `AcceptedCredential[]` | Yes | The credentials the domain accepts (at least one). | + +Each `AcceptedCredential` is: + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `issuer` | `string` | Yes | The issuer r-address. | +| `credType` | `string` | Yes | The credential type, as a plain string (hex-encoded on the ledger). | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Domain.create`, the `intent` (`DomainIntent`) carries: + +| Field | Type | Description | +| --- | --- | --- | +| `domainID` | `string` | The id of the newly created domain, discovered from the transaction result. | + +## Underlying XRPL transactor + +Builds and submits a single [PermissionedDomainSet](https://xrpl.org/docs/references/protocol/transactions/types/permissioneddomainset) transaction (with no domain id, creating a new domain). + +## Example + +```ts +const { intent } = await client.domain.create({ + credList: [{ issuer: 'rIssuer...', credType: 'KYC' }], +}) + +console.log(intent.domainID) +``` diff --git a/docs/simpleXRPL/references/verticals/domain/delete.md b/docs/simpleXRPL/references/verticals/domain/delete.md new file mode 100644 index 00000000..94420172 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/domain/delete.md @@ -0,0 +1,58 @@ +--- +seo: + description: Domain.delete deletes a permissioned domain via a PermissionedDomainDelete transaction. +labels: + - simpleXRPL + - SDK +--- + +# domain.delete() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/domain.ts#L123) + +Delete a permissioned domain. + +## Signature + +```ts +domain.delete( + params: DomainDeleteParams, + options?: DomainWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `domain` | `string` | Yes | The domain id to delete. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Domain.delete`, the `intent` (`DomainIntent`) echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `domainID` | `string` | The domain id that was deleted. | + +## Underlying XRPL transactor + +Builds and submits a single [PermissionedDomainDelete](https://xrpl.org/docs/references/protocol/transactions/types/permissioneddomaindelete) transaction. + +## Example + +```ts +await client.domain.delete({ + domain: 'A1B2...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/domain/index.md b/docs/simpleXRPL/references/verticals/domain/index.md new file mode 100644 index 00000000..676c2a09 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/domain/index.md @@ -0,0 +1,19 @@ +--- +seo: + description: The Domain vertical in simpleXRPL creates, updates, and deletes permissioned domains. +labels: + - simpleXRPL + - SDK +--- + +# Domain + +The `Domain` vertical creates, updates, and deletes [permissioned domains](https://xrpl.org/docs/concepts/tokens/decentralized-exchange/permissioned-dexes). + +| Method | Description | +| --- | --- | +| [create](create.md) | Create a new permissioned domain. | +| [setCredentials](setCredentials.md) | Update the accepted credentials of an existing domain. | +| [delete](delete.md) | Delete a permissioned domain. | +| [retrieve](retrieve.md) | Read a single permissioned domain by id. | +| [list](list.md) | List the permissioned domains an account owns. | diff --git a/docs/simpleXRPL/references/verticals/domain/list.md b/docs/simpleXRPL/references/verticals/domain/list.md new file mode 100644 index 00000000..c64cd156 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/domain/list.md @@ -0,0 +1,50 @@ +--- +seo: + description: Domain.list lists every permissioned domain owned by an account. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# domain.list() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/domain.ts#L59) + +List every permissioned domain owned by an account. + +## Signature + +```ts +domain.list( + params?: DomainListParams +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `account` | `string` | No | The owner whose domains to list. Defaults to the primary signer's account. | + +## Returns + +Resolves to a `DomainListResult`, where `domains[i]` corresponds to `data[i]`: + +| Field | Type | Description | +| --- | --- | --- | +| `domains` | `readonly string[]` | The domain id of each owned domain. | +| `data` | `readonly DomainData[]` | The shaped domains. See [domain.retrieve](retrieve.md#domaindata) for `DomainData`. | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [account_objects](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/account-methods/account_objects). + +## Example + +```ts +const { data } = await client.domain.list() + +for (const domain of data) { + console.log(domain.domainID) +} +``` diff --git a/docs/simpleXRPL/references/verticals/domain/retrieve.md b/docs/simpleXRPL/references/verticals/domain/retrieve.md new file mode 100644 index 00000000..9ac98a08 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/domain/retrieve.md @@ -0,0 +1,58 @@ +--- +seo: + description: Domain.retrieve reads a permissioned domain by id. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# domain.retrieve() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/domain.ts#L47) + +Retrieve a permissioned domain by id (point-in-time). + +## Signature + +```ts +domain.retrieve( + params: DomainRetrieveParams, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `domainID` | `string` | Yes | The domain id to fetch. | + +## Returns + +Resolves to a `DomainRetrieveResult`: + +| Field | Type | Description | +| --- | --- | --- | +| `domainID` | `string` | The queried domain id. | +| `data` | `DomainData \| undefined` | The domain snapshot, or `undefined` if no such domain exists. | + +### DomainData + +| Field | Type | Description | +| --- | --- | --- | +| `domainID` | `string` | The domain's on-chain id. | +| `owner` | `string` | The owning account's r-address. | +| `credList` | `readonly AcceptedCredential[]` | The credentials the domain accepts (each `{ issuer, credType }`, credential types decoded from hex). | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [ledger_entry](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/ledger-methods/ledger_entry). + +## Example + +```ts +const { data } = await client.domain.retrieve({ + domainID: 'A1B2...', +}) + +console.log(data?.owner) +``` diff --git a/docs/simpleXRPL/references/verticals/domain/setCredentials.md b/docs/simpleXRPL/references/verticals/domain/setCredentials.md new file mode 100644 index 00000000..bba9aa8e --- /dev/null +++ b/docs/simpleXRPL/references/verticals/domain/setCredentials.md @@ -0,0 +1,67 @@ +--- +seo: + description: Domain.setCredentials updates the accepted credentials of an existing permissioned domain via a PermissionedDomainSet transaction. +labels: + - simpleXRPL + - SDK +--- + +# domain.setCredentials() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/domain.ts#L96) + +Update the accepted credentials of an existing permissioned domain. + +## Signature + +```ts +domain.setCredentials( + params: DomainSetCredentialsParams, + options?: DomainWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `domain` | `string` | Yes | The domain id to update. | +| `credList` | `AcceptedCredential[]` | Yes | The credentials the domain accepts (at least one). | + +Each `AcceptedCredential` is: + +| Field | Type | Required | Description | +| --- | --- | --- | --- | +| `issuer` | `string` | Yes | The issuer r-address. | +| `credType` | `string` | Yes | The credential type, as a plain string (hex-encoded on the ledger). | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Domain.setCredentials`, the `intent` (`DomainIntent`) echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `domainID` | `string` | The domain id that was updated. | + +## Underlying XRPL transactor + +Builds and submits a single [PermissionedDomainSet](https://xrpl.org/docs/references/protocol/transactions/types/permissioneddomainset) transaction naming the existing domain id. + +## Example + +```ts +await client.domain.setCredentials({ + domain: 'A1B2...', + credList: [{ issuer: 'rIssuer...', credType: 'KYC' }], +}) +``` diff --git a/docs/simpleXRPL/references/verticals/index.md b/docs/simpleXRPL/references/verticals/index.md new file mode 100644 index 00000000..cab6e91a --- /dev/null +++ b/docs/simpleXRPL/references/verticals/index.md @@ -0,0 +1,26 @@ +--- +seo: + description: A vertical is a domain-specific class of business-intent operations in simpleXRPL — one per area of XRPL functionality, reached off the client. +labels: + - simpleXRPL + - SDK +--- + +# Verticals + +A **vertical** is a domain-specific class that groups related operations — one per area of XRPL functionality. Each vertical's methods are the _business-intent verbs_ for that domain (`token.issue(...)`, `iou.transfer(...)`), and each vertical is reached off the client under a lowercase name (`client.token`, `client.iou`). The term contrasts with _horizontal_ operations that cut across domains, such as payments and batch transactions. + +Most vertical methods submit a transaction and resolve to a `Promise>`, where `T` is the method's typed intent output; they also accept an optional second argument to target a non-primary account and override the fee. (A few helpers differ — for example, `Account.create` generates a keypair and returns synchronously.) Each vertical's page lists its methods; every method has its own page with parameters, response, and the underlying XRPL transactor(s). + +| Vertical | Reached as | What it does | +| --- | --- | --- | +| [XRP](xrp/index.md) | `client.xrp` | Native XRP payments. | +| [Token](token/index.md) | `client.token` | Issue and manage [Multi-Purpose Tokens (MPTs)](https://xrpl.org/docs/concepts/tokens/fungible-tokens/multi-purpose-tokens) and place DEX offers. | +| [IOU](iou/index.md) | `client.iou` | Issue and manage trust line-based issued currencies. | +| [Credential](credential/index.md) | `client.credential` | Issue, accept, and delete on-ledger [credentials](https://xrpl.org/docs/concepts/decentralized-storage/credentials). | +| [Domain](domain/index.md) | `client.domain` | Create, update, and delete [permissioned domains](https://xrpl.org/docs/concepts/tokens/decentralized-exchange/permissioned-dexes). | +| [Account](account/index.md) | `client.account` | Account creation, funding, and administration. | + +{% admonition type="info" name="Note" %} +Where a vertical's natural class name would collide with a type, the class is suffixed — the Account vertical's class is `AccountVertical` — but it is still reached as `client.account`. +{% /admonition %} diff --git a/docs/simpleXRPL/references/verticals/iou/authorize.md b/docs/simpleXRPL/references/verticals/iou/authorize.md new file mode 100644 index 00000000..b95053ea --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/authorize.md @@ -0,0 +1,64 @@ +--- +seo: + description: IOU.authorize authorizes a holder to hold an IOU via a TrustSet transaction with the authorize flag. +labels: + - simpleXRPL + - SDK +--- + +# iou.authorize() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L152) + +Grant authorization for a holder to hold this IOU. Only meaningful when the issuer's account has `asfRequireAuth` set. + +{% admonition type="info" name="Note" %} +There is no matching `unauthorize`: the underlying authorize flag is one-way and cannot be cleared once set. To reversibly block a trust line, use [IOU.lock](lock.md) instead. +{% /admonition %} + +## Signature + +```ts +iou.authorize( + params: IOUAuthorizeParams, + options?: IOUWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `ticker` | `string` | Yes | The currency code (3-character ISO-4217-style or 40-character hex; other codes are auto-encoded to hex). | +| `holder` | `string` | Yes | The holder's r-address being authorized. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `IOU.authorize`, the `intent` (`IOUAuthorizeIntent`) echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `holder` | `string` | The holder's r-address that was authorized. | + +## Underlying XRPL transactor + +Builds and submits a single [TrustSet](https://xrpl.org/docs/references/protocol/transactions/types/trustset) transaction with the authorize flag set. + +## Example + +```ts +await client.iou.authorize({ + ticker: 'USD', + holder: 'rHolder...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/iou/buyOffer.md b/docs/simpleXRPL/references/verticals/iou/buyOffer.md new file mode 100644 index 00000000..a2da14c3 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/buyOffer.md @@ -0,0 +1,71 @@ +--- +seo: + description: IOU.buyOffer places a DEX order to acquire more of this IOU via an OfferCreate transaction. +labels: + - simpleXRPL + - SDK +--- + +# iou.buyOffer() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L303) + +Place an order on the DEX to acquire more of this IOU. + +## Signature + +```ts +iou.buyOffer( + params: IOUOfferParams, + options?: IOUWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `ticker` | `string` | Yes | The currency code (3-character ISO-4217-style or 40-character hex; other codes are auto-encoded to hex). | +| `amount` | `number` | Yes | The number of units of this IOU to buy. | +| `orderType` | `IOUOrderType` | Yes | The order type: `'limit'`, `'market'`, `'fok'`, or `'passive'`. | +| `price` | `IOUOfferPrice` | Yes | What's offered in payment — XRP, an MPT, or another IOU (see below). | +| `domainID` | `string` | No | Restrict the offer to a permissioned domain. Omit for the open DEX. | +| `hybrid` | `boolean` | No | Whether a domain-scoped offer also works the open DEX. Only meaningful with `domainID`; defaults to `true` when `domainID` is set. | +| `offerSequence` | `number` | No | A prior offer sequence to replace. | + +`price` (`IOUOfferPrice`) is one of: + +| Shape | Description | +| --- | --- | +| `{ currency: 'XRP'; amount: number }` | Priced in XRP. | +| `{ mptIssuanceId: string; amount: number }` | Priced in an MPT. | +| `{ ticker: string; issuer: string; amount: number }` | Priced in another IOU. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +`IOU.buyOffer` attaches no `intent` output; `intent` is `undefined`. + +## Underlying XRPL transactor + +Builds and submits a single [OfferCreate](https://xrpl.org/docs/references/protocol/transactions/types/offercreate) transaction. Throws an `IntentValidationError` if `price` is MPT-denominated. + +## Example + +```ts +await client.iou.buyOffer({ + ticker: 'USD', + amount: 100, + orderType: 'limit', + price: { currency: 'XRP', amount: 50 }, +}) +``` diff --git a/docs/simpleXRPL/references/verticals/iou/cancelOffer.md b/docs/simpleXRPL/references/verticals/iou/cancelOffer.md new file mode 100644 index 00000000..39424e8d --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/cancelOffer.md @@ -0,0 +1,58 @@ +--- +seo: + description: IOU.cancelOffer cancels a standing DEX offer placed by the issuer via an OfferCancel transaction. +labels: + - simpleXRPL + - SDK +--- + +# iou.cancelOffer() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L335) + +Cancel a standing offer placed by this IOU's issuer. + +## Signature + +```ts +iou.cancelOffer( + params: IOUCancelOfferParams, + options?: IOUWriteOptions, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `offerSequence` | `number` | Yes | The sequence number of the offer to cancel. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult<{ offerSequence: number }>`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `IOU.cancelOffer`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `offerSequence` | `number` | The sequence number of the offer that was canceled. | + +## Underlying XRPL transactor + +Builds and submits a single [OfferCancel](https://xrpl.org/docs/references/protocol/transactions/types/offercancel) transaction. + +## Example + +```ts +await client.iou.cancelOffer({ + offerSequence: 42, +}) +``` diff --git a/docs/simpleXRPL/references/verticals/iou/clawback.md b/docs/simpleXRPL/references/verticals/iou/clawback.md new file mode 100644 index 00000000..e9278c6c --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/clawback.md @@ -0,0 +1,67 @@ +--- +seo: + description: IOU.clawback reclaims a holder's balance back to the issuer via a Clawback transaction. +labels: + - simpleXRPL + - SDK +--- + +# iou.clawback() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L234) + +Reclaim a holder's balance back to the issuer. + +{% admonition type="info" name="Note" %} +Verifies the issuer has `asfAllowTrustLineClawback` enabled first (a ledger read), throwing a clear error if not. The flag can only be enabled before the issuer owns any trust lines, offers, or other ledger objects, which this SDK does not itself pre-check. +{% /admonition %} + +## Signature + +```ts +iou.clawback( + params: IOUClawbackParams, + options?: IOUWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `ticker` | `string` | Yes | The currency code (3-character ISO-4217-style or 40-character hex; other codes are auto-encoded to hex). | +| `holder` | `string` | Yes | The holder's r-address to claw the currency back from. | +| `amount` | `number` | Yes | The amount to claw back. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `IOU.clawback`, the `intent` (`IOUClawbackIntent`) echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `holder` | `string` | The holder's r-address clawed back from. | +| `amount` | `number` | The amount clawed back. | + +## Underlying XRPL transactor + +Builds and submits a single [Clawback](https://xrpl.org/docs/references/protocol/transactions/types/clawback) transaction. + +## Example + +```ts +await client.iou.clawback({ + ticker: 'USD', + holder: 'rHolder...', + amount: 50, +}) +``` diff --git a/docs/simpleXRPL/references/verticals/iou/index.md b/docs/simpleXRPL/references/verticals/iou/index.md new file mode 100644 index 00000000..8c1bcb07 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/index.md @@ -0,0 +1,26 @@ +--- +seo: + description: The IOU vertical in simpleXRPL issues and manages trust line-based issued currencies. +labels: + - simpleXRPL + - SDK +--- + +# IOU + +The `IOU` vertical issues and manages trust line-based issued currencies. Each verb acts as the IOU's **issuer** — the account resolved from `from` (default: the primary signer's account) signs, and its address is the currency issuer. Callers name their own counterparty (`holder` / `destination`) per call. + +| Method | Description | +| --- | --- | +| [issue](issue.md) | Bootstrap a new trust line-based IOU between two environment-sourced accounts. | +| [transfer](transfer.md) | Send IOU value to a destination account. | +| [authorize](authorize.md) | Authorize a holder to hold this IOU. | +| [lock](lock.md) | Freeze a holder's trust line (individual + deep freeze). | +| [unlock](unlock.md) | Restore a frozen holder's trust line. | +| [clawback](clawback.md) | Reclaim a holder's balance back to the issuer. | +| [buyOffer](buyOffer.md) | Place a DEX order to acquire this IOU. | +| [sellOffer](sellOffer.md) | Place a DEX order to sell this IOU. | +| [cancelOffer](cancelOffer.md) | Cancel a standing offer. | +| [retrieve](retrieve.md) | Read a single IOU trust line. | +| [list](list.md) | List an account's IOU trust lines. | +| [listOffers](listOffers.md) | List all open offers in the market for an IOU. | diff --git a/docs/simpleXRPL/references/verticals/iou/issue.md b/docs/simpleXRPL/references/verticals/iou/issue.md new file mode 100644 index 00000000..54245cb2 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/issue.md @@ -0,0 +1,64 @@ +--- +seo: + description: IOU.issue bootstraps a new trust line-based IOU between two environment-sourced accounts via AccountSet and TrustSet transactions. +labels: + - simpleXRPL + - SDK +--- + +# iou.issue() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L83) + +Generate a new trust line-based IOU between two developer-controlled accounts sourced from the environment. + +{% admonition type="info" name="Note" %} +Unlike the other IOU verbs, `issue` takes no `options`. It bootstraps both accounts from the environment: it reads `XRPL_ISSUER_SEED` and `XRPL_HOT_WALLET_SEED`, has the issuer enable rippling, then has the hot wallet extend trust up to the maximum limit. No `Payment` runs, so no value exists yet. Use [IOU.transfer](transfer.md) to send some. +{% /admonition %} + +## Signature + +```ts +iou.issue( + params: IOUIssueParams, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `ticker` | `string` | Yes | The currency code: a 3-character ISO-4217-style code or a 40-character hex code. Any other code (e.g., a 5-character ticker) is auto-encoded to the 40-character hex form. | + +## Returns + +Resolves to a `SubmissionResult` (from the final step). + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `IOU.issue`, the `intent` (`IOUIssueIntent`) carries: + +| Field | Type | Description | +| --- | --- | --- | +| `iouID` | `string` | The currency code and issuer of the new IOU, e.g. `USD.rIssuer...`. | + +## Underlying XRPL transactors + +Runs as an ordered, multi-step sequence (no rollback on partial failure): + +1. [AccountSet](https://xrpl.org/docs/references/protocol/transactions/types/accountset) — the issuer enables rippling (`defaultRipple`). +2. [TrustSet](https://xrpl.org/docs/references/protocol/transactions/types/trustset) — the hot wallet extends trust to the issuer, up to the maximum limit. + +Throws an `IntentValidationError` if the required seeds aren't set, or a `MultiStepFailureError` if either step fails. + +## Example + +```ts +const { intent } = await client.iou.issue({ + ticker: 'USD', +}) + +console.log(intent.iouID) +``` diff --git a/docs/simpleXRPL/references/verticals/iou/list.md b/docs/simpleXRPL/references/verticals/iou/list.md new file mode 100644 index 00000000..3ea262eb --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/list.md @@ -0,0 +1,51 @@ +--- +seo: + description: IOU.list lists every IOU trust line for an account. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# iou.list() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L119) + +List every IOU trust line for an account. + +## Signature + +```ts +iou.list( + params?: IOUListParams +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `role` | `'holder' \| 'issuer'` | No | Query as `holder` (default) or `issuer`. | +| `account` | `string` | No | The account whose trust lines to list. Defaults to the primary signer's account. | + +## Returns + +Resolves to an `IOUListResult`, where `ious[i]` corresponds to `data[i]`: + +| Field | Type | Description | +| --- | --- | --- | +| `ious` | `readonly string[]` | The `iouID` of each line, composable into the write verbs. | +| `data` | `readonly IOUTrustLine[]` | The shaped trust lines. See [iou.retrieve](retrieve.md#ioutrustline) for `IOUTrustLine`. | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [account_lines](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/account-methods/account_lines). + +## Example + +```ts +const { data } = await client.iou.list() + +for (const line of data) { + console.log(line.currency, line.balance) +} +``` diff --git a/docs/simpleXRPL/references/verticals/iou/listOffers.md b/docs/simpleXRPL/references/verticals/iou/listOffers.md new file mode 100644 index 00000000..c9612fe9 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/listOffers.md @@ -0,0 +1,53 @@ +--- +seo: + description: IOU.listOffers lists all open offers in the market for an IOU (both sides of the order book). Read-only. +labels: + - simpleXRPL + - SDK +--- + +# iou.listOffers() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L130) + +List all open offers in the market for this IOU (both sides), tagged buy/sell relative to it. + +{% admonition type="info" name="Note" %} +Unlike [token.listOffers](../token/listOffers.md) and [account.listOffers](../account/listOffers.md) — which list a single **account's own** resting offers — `iou.listOffers` reads the whole **order book** for the IOU across all accounts. +{% /admonition %} + +## Signature + +```ts +iou.listOffers( + params: IOUListOffersParams, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `ticker` | `string` | Yes | The IOU currency code to anchor the book on. | +| `issuer` | `string` | Yes | The IOU issuer's r-address. | + +## Returns + +Resolves to a `ListOffersResult`: + +| Field | Type | Description | +| --- | --- | --- | +| `data` | `readonly OfferSummary[]` | The shaped open offers, tagged buy/sell relative to the IOU. See [token.listOffers](../token/listOffers.md#offersummary) for `OfferSummary`. | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries both sides of the order book with [book_offers](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/path-and-order-book-methods/book_offers). + +## Example + +```ts +const { data } = await client.iou.listOffers({ + ticker: 'USD', + issuer: 'rIssuer...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/iou/lock.md b/docs/simpleXRPL/references/verticals/iou/lock.md new file mode 100644 index 00000000..2011b5f2 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/lock.md @@ -0,0 +1,65 @@ +--- +seo: + description: IOU.lock freezes a holder's trust line via individual and deep freeze TrustSet transactions. +labels: + - simpleXRPL + - SDK +--- + +# iou.lock() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L187) + +Freeze a holder's ability to send and receive this IOU: an individual freeze followed by a deep freeze. + +## Signature + +```ts +iou.lock( + params: IOULockParams, + options?: IOUWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `ticker` | `string` | Yes | The currency code (3-character ISO-4217-style or 40-character hex; other codes are auto-encoded to hex). | +| `holder` | `string` | Yes | The holder's r-address whose trust line is locked. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult` (from the final step). + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `IOU.lock`, the `intent` (`IOULockIntent`) echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `holder` | `string` | The holder's r-address whose trust line was locked. | + +## Underlying XRPL transactors + +Runs as an ordered, multi-step sequence (no rollback on partial failure): + +1. [TrustSet](https://xrpl.org/docs/references/protocol/transactions/types/trustset) — sets the individual freeze. +2. [TrustSet](https://xrpl.org/docs/references/protocol/transactions/types/trustset) — sets the deep freeze. + +Throws a `MultiStepFailureError` if either step fails. + +## Example + +```ts +await client.iou.lock({ + ticker: 'USD', + holder: 'rHolder...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/iou/retrieve.md b/docs/simpleXRPL/references/verticals/iou/retrieve.md new file mode 100644 index 00000000..8e747426 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/retrieve.md @@ -0,0 +1,66 @@ +--- +seo: + description: IOU.retrieve reads a single IOU trust line between an account and an issuer. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# iou.retrieve() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L109) + +Read a single IOU trust line (point-in-time). + +## Signature + +```ts +iou.retrieve( + params: IOURetrieveParams +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `ticker` | `string` | Yes | The currency code (3-character ISO-4217-style or 40-character hex; other codes are auto-encoded to hex). | +| `issuer` | `string` | Yes | The IOU issuer's r-address. | +| `account` | `string` | No | The holder account to read from. Defaults to the primary signer's account. | + +## Returns + +Resolves to an `IOURetrieveResult`: + +| Field | Type | Description | +| --- | --- | --- | +| `iouID` | `string` | Currency code and issuer, e.g. `USD.rIssuer...` — pass to the write verbs. | +| `data` | `IOUTrustLine \| undefined` | The point-in-time trust line snapshot, or `undefined` if no line exists. | + +### IOUTrustLine + +| Field | Type | Description | +| --- | --- | --- | +| `currency` | `string` | The currency ticker (hex codes decoded to ASCII where printable). | +| `peer` | `string` | The counterparty r-address (the issuer, when querying as `holder`). | +| `balance` | `string` | The trust line balance, from the queried account's perspective. | +| `limit` | `string` | The queried account's trust limit. | +| `limitPeer` | `string` | The counterparty's trust limit. | +| `noRipple` | `boolean` | Whether rippling is disabled on this line. | +| `frozen` | `boolean` | Whether the queried account has frozen this line. | +| `authorized` | `boolean` | Whether the line is authorized (issuer authorized the holder). | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [account_lines](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/account-methods/account_lines). + +## Example + +```ts +const { data } = await client.iou.retrieve({ + ticker: 'USD', + issuer: 'rIssuer...', +}) + +console.log(data?.balance) +``` diff --git a/docs/simpleXRPL/references/verticals/iou/sellOffer.md b/docs/simpleXRPL/references/verticals/iou/sellOffer.md new file mode 100644 index 00000000..2e333468 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/sellOffer.md @@ -0,0 +1,71 @@ +--- +seo: + description: IOU.sellOffer places a DEX order to sell this IOU via an OfferCreate transaction. +labels: + - simpleXRPL + - SDK +--- + +# iou.sellOffer() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L319) + +Place an order on the DEX to sell this IOU. + +## Signature + +```ts +iou.sellOffer( + params: IOUOfferParams, + options?: IOUWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `ticker` | `string` | Yes | The currency code (3-character ISO-4217-style or 40-character hex; other codes are auto-encoded to hex). | +| `amount` | `number` | Yes | The number of units of this IOU to sell. | +| `orderType` | `IOUOrderType` | Yes | The order type: `'limit'`, `'market'`, `'fok'`, or `'passive'`. | +| `price` | `IOUOfferPrice` | Yes | What's wanted in return — XRP, an MPT, or another IOU (see below). | +| `domainID` | `string` | No | Restrict the offer to a permissioned domain. Omit for the open DEX. | +| `hybrid` | `boolean` | No | Whether a domain-scoped offer also works the open DEX. Only meaningful with `domainID`; defaults to `true` when `domainID` is set. | +| `offerSequence` | `number` | No | A prior offer sequence to replace. | + +`price` (`IOUOfferPrice`) is one of: + +| Shape | Description | +| --- | --- | +| `{ currency: 'XRP'; amount: number }` | Priced in XRP. | +| `{ mptIssuanceId: string; amount: number }` | Priced in an MPT. | +| `{ ticker: string; issuer: string; amount: number }` | Priced in another IOU. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +`IOU.sellOffer` attaches no `intent` output; `intent` is `undefined`. + +## Underlying XRPL transactor + +Builds and submits a single [OfferCreate](https://xrpl.org/docs/references/protocol/transactions/types/offercreate) transaction. Throws an `IntentValidationError` if `price` is MPT-denominated. + +## Example + +```ts +await client.iou.sellOffer({ + ticker: 'USD', + amount: 100, + orderType: 'limit', + price: { currency: 'XRP', amount: 50 }, +}) +``` diff --git a/docs/simpleXRPL/references/verticals/iou/transfer.md b/docs/simpleXRPL/references/verticals/iou/transfer.md new file mode 100644 index 00000000..a8741c83 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/transfer.md @@ -0,0 +1,63 @@ +--- +seo: + description: IOU.transfer sends issued-currency value to a destination account via a Payment transaction. +labels: + - simpleXRPL + - SDK +--- + +# iou.transfer() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L267) + +Send a specified amount of this IOU to a destination account. + +## Signature + +```ts +iou.transfer( + params: IOUTransferParams, + options?: IOUWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `ticker` | `string` | Yes | The currency code (3-character ISO-4217-style or 40-character hex; other codes are auto-encoded to hex). | +| `destination` | `string` | Yes | The destination r-address. | +| `amount` | `number` | Yes | The amount to send. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `IOU.transfer`, the `intent` (`IOUTransferIntent`) echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `destination` | `string` | Destination r-address. | +| `amount` | `number` | Amount sent. | + +## Underlying XRPL transactor + +Builds and submits a single [Payment](https://xrpl.org/docs/references/protocol/transactions/types/payment) transaction. + +## Example + +```ts +await client.iou.transfer({ + ticker: 'USD', + destination: 'rHolder...', + amount: 100, +}) +``` diff --git a/docs/simpleXRPL/references/verticals/iou/unlock.md b/docs/simpleXRPL/references/verticals/iou/unlock.md new file mode 100644 index 00000000..b08bd6a4 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/iou/unlock.md @@ -0,0 +1,65 @@ +--- +seo: + description: IOU.unlock restores a frozen holder's trust line by clearing deep and individual freeze via TrustSet transactions. +labels: + - simpleXRPL + - SDK +--- + +# iou.unlock() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/iou.ts#L209) + +Restore a holder's ability to send and receive this IOU: clears the deep freeze, then the individual freeze. + +## Signature + +```ts +iou.unlock( + params: IOULockParams, + options?: IOUWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `ticker` | `string` | Yes | The currency code (3-character ISO-4217-style or 40-character hex; other codes are auto-encoded to hex). | +| `holder` | `string` | Yes | The holder's r-address whose trust line is unlocked. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult` (from the final step). + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `IOU.unlock`, the `intent` (`IOULockIntent`) echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `holder` | `string` | The holder's r-address whose trust line was unlocked. | + +## Underlying XRPL transactors + +Runs as an ordered, multi-step sequence (no rollback on partial failure): + +1. [TrustSet](https://xrpl.org/docs/references/protocol/transactions/types/trustset) — clears the deep freeze. +2. [TrustSet](https://xrpl.org/docs/references/protocol/transactions/types/trustset) — clears the individual freeze. + +Throws a `MultiStepFailureError` if either step fails. + +## Example + +```ts +await client.iou.unlock({ + ticker: 'USD', + holder: 'rHolder...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/token/authorize.md b/docs/simpleXRPL/references/verticals/token/authorize.md new file mode 100644 index 00000000..ee3b4e71 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/authorize.md @@ -0,0 +1,58 @@ +--- +seo: + description: Token.authorize opts the calling account in to holding an MPT issuance via an MPTokenAuthorize transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.authorize() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L155) + +Opt the calling account in to hold an MPT issuance. + +## Signature + +```ts +token.authorize( + params: MptAuthorizeParams, + options?: TokenWriteOptions, +): Promise`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Token.authorize`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `mptIssuanceId` | `string` | The MPT issuance id that was authorized. | + +## Underlying XRPL transactor + +Builds and submits a single [MPTokenAuthorize](https://xrpl.org/docs/references/protocol/transactions/types/mptokenauthorize) transaction. + +## Example + +```ts +await client.token.authorize({ + mptIssuanceId: '005C...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/token/cancelOffer.md b/docs/simpleXRPL/references/verticals/token/cancelOffer.md new file mode 100644 index 00000000..a1afc48c --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/cancelOffer.md @@ -0,0 +1,58 @@ +--- +seo: + description: Token.cancelOffer cancels a standing DEX offer via an OfferCancel transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.cancelOffer() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L336) + +Cancel a standing offer. + +## Signature + +```ts +token.cancelOffer( + params: CancelOfferParams, + options?: TokenWriteOptions, +): Promise`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Token.cancelOffer`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `offerSequence` | `number` | The sequence number of the offer that was canceled. | + +## Underlying XRPL transactor + +Builds and submits a single [OfferCancel](https://xrpl.org/docs/references/protocol/transactions/types/offercancel) transaction. + +## Example + +```ts +await client.token.cancelOffer({ + offerSequence: 42, +}) +``` diff --git a/docs/simpleXRPL/references/verticals/token/createOffer.md b/docs/simpleXRPL/references/verticals/token/createOffer.md new file mode 100644 index 00000000..29b59ff4 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/createOffer.md @@ -0,0 +1,70 @@ +--- +seo: + description: Token.createOffer places an offer on the XRP Ledger decentralized exchange via an OfferCreate transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.createOffer() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L299) + +Place an offer on the decentralized exchange (DEX). + +## Signature + +```ts +token.createOffer( + params: CreateOfferParams, + options?: TokenWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `takerGets` | `Amount` | Yes | What the account gives (XRP or IOU — MPT is not DEX-tradeable). | +| `takerPays` | `Amount` | Yes | What the account wants (XRP or IOU). | +| `expiration` | `number` | No | Offer expiration, in seconds since the Ripple epoch. | +| `offerSequence` | `number` | No | A prior offer sequence to replace. | +| `flags` | `OfferFlags` | No | Offer flags (see below). | + +The `flags` object accepts: + +| Flag | Type | Required | Description | +| --- | --- | --- | --- | +| `passive` | `boolean` | No | Do not consume offers that exactly match. | +| `immediateOrCancel` | `boolean` | No | Consume matching offers immediately; never place the remainder. | +| `fillOrKill` | `boolean` | No | Consume the full amount or cancel entirely. | +| `sell` | `boolean` | No | Interpret the offer as selling `takerGets`. | + +{% raw-partial file="/docs/_snippets/simplexrpl-amount.md" /%} + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +`Token.createOffer` attaches no `intent` output; `intent` is `undefined`. + +## Underlying XRPL transactor + +Builds and submits a single [OfferCreate](https://xrpl.org/docs/references/protocol/transactions/types/offercreate) transaction. Throws an `IntentValidationError` if either amount is an MPT. + +## Example + +```ts +await client.token.createOffer({ + takerGets: { asset: XRP_ASSET, value: '10' }, + takerPays: { asset: iou('USD', 'rIssuer...'), value: '5' }, +}) +``` diff --git a/docs/simpleXRPL/references/verticals/token/destroy.md b/docs/simpleXRPL/references/verticals/token/destroy.md new file mode 100644 index 00000000..df4ca11a --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/destroy.md @@ -0,0 +1,58 @@ +--- +seo: + description: Token.destroy destroys an MPT issuance via an MPTokenIssuanceDestroy transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.destroy() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L239) + +Destroy an MPT issuance. Only succeeds when no tokens are outstanding. + +## Signature + +```ts +token.destroy( + params: MptDestroyParams, + options?: TokenWriteOptions, +): Promise`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Token.destroy`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `mptIssuanceId` | `string` | The MPT issuance id that was destroyed. | + +## Underlying XRPL transactor + +Builds and submits a single [MPTokenIssuanceDestroy](https://xrpl.org/docs/references/protocol/transactions/types/mptokenissuancedestroy) transaction. + +## Example + +```ts +await client.token.destroy({ + mptIssuanceId: '005C...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/token/grantHolder.md b/docs/simpleXRPL/references/verticals/token/grantHolder.md new file mode 100644 index 00000000..2be27c73 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/grantHolder.md @@ -0,0 +1,60 @@ +--- +seo: + description: Token.grantHolder lets an issuer authorize a specific holder to hold an MPT via an MPTokenAuthorize transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.grantHolder() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L183) + +As the issuer, grant a specific holder permission to hold this MPT (allow-listing). Use this when the issuance requires authorization. + +## Signature + +```ts +token.grantHolder( + params: MptHolderParams, + options?: TokenWriteOptions, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `mptIssuanceId` | `string` | Yes | The MPT issuance id. | +| `holder` | `string` | Yes | The r-address of the holder to grant. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult<{ mptIssuanceId: string }>`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Token.grantHolder`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `mptIssuanceId` | `string` | The MPT issuance id the holder was granted on. | + +## Underlying XRPL transactor + +Builds and submits a single [MPTokenAuthorize](https://xrpl.org/docs/references/protocol/transactions/types/mptokenauthorize) transaction naming the holder. + +## Example + +```ts +await client.token.grantHolder({ + mptIssuanceId: '005C...', + holder: 'rHolder...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/token/index.md b/docs/simpleXRPL/references/verticals/token/index.md new file mode 100644 index 00000000..8864892c --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/index.md @@ -0,0 +1,28 @@ +--- +seo: + description: The Token vertical in simpleXRPL issues and manages Multi-Purpose Tokens (MPTs) and places DEX offers. +labels: + - simpleXRPL + - SDK +--- + +# Token + +The `Token` vertical issues and manages [Multi-Purpose Tokens (MPTs)](https://xrpl.org/docs/concepts/tokens/fungible-tokens/multi-purpose-tokens) and places offers on the decentralized exchange. + +| Method | Description | +| --- | --- | +| [issue](issue.md) | Create a new MPT issuance. | +| [transfer](transfer.md) | Send MPT units to another account. | +| [authorize](authorize.md) | Opt the calling account in to holding a token. | +| [unauthorize](unauthorize.md) | Opt the calling account out of holding a token. | +| [grantHolder](grantHolder.md) | Issuer authorizes a specific holder (allow-listing). | +| [revokeHolder](revokeHolder.md) | Issuer revokes a specific holder's permission. | +| [lock](lock.md) | Lock a token issuance, or a specific holder's balance. | +| [unlock](unlock.md) | Unlock a token issuance, or a specific holder's balance. | +| [destroy](destroy.md) | Destroy an MPT issuance. | +| [createOffer](createOffer.md) | Place an offer on the DEX. | +| [cancelOffer](cancelOffer.md) | Cancel a standing offer. | +| [retrieve](retrieve.md) | Read a single MPT issuance by id. | +| [list](list.md) | List the MPTs an account holds or issued. | +| [listOffers](listOffers.md) | List the DEX offers placed by an account. | diff --git a/docs/simpleXRPL/references/verticals/token/issue.md b/docs/simpleXRPL/references/verticals/token/issue.md new file mode 100644 index 00000000..1c247638 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/issue.md @@ -0,0 +1,86 @@ +--- +seo: + description: Token.issue creates a new Multi-Purpose Token (MPT) issuance via an MPTokenIssuanceCreate transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.issue() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L134) + +Create a new MPT issuance. + +## Signature + +```ts +token.issue( + params: MptIssueParams, + options?: TokenWriteOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `metadata` | `MPTokenMetadata \| string` | Yes | Token metadata: a structured object (encoded per the [XLS-89 standard](https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0089-multi-purpose-token-metadata-schema)) or a raw string (UTF-8 hex-encoded as-is). Validated against XLS-89; non-compliant metadata is rejected before submission. | +| `assetScale` | `number` | No | Decimal places between the display value and base units. Defaults to `2`. | +| `maximumAmount` | `string` | No | Maximum issuable amount, in base units. | +| `transferFee` | `number` | No | Transfer fee on secondary sales, as a percentage (`0.5` = 0.5%, range 0–50). | +| `flags` | `MptIssueFlags` | No | Capability flags (see below). | + +The `flags` object accepts: + +| Flag | Type | Required | Description | +| --- | --- | --- | --- | +| `canLock` | `boolean` | No | The issuer can lock the token (globally or per-holder). | +| `requireAuth` | `boolean` | No | Holders must be authorized before they can hold the token. | +| `canEscrow` | `boolean` | No | The token can be used in escrows. | +| `canTrade` | `boolean` | No | The token can be traded on the DEX. | +| `canTransfer` | `boolean` | No | The token can be transferred between holders. | +| `canClawback` | `boolean` | No | The issuer can claw back the token. | + +{% admonition type="info" name="Note" %} +`issue()` applies opinionated, overridable defaults so a bare call yields a usable token: `canLock`, `canEscrow`, `canTrade`, `canTransfer`, and `canClawback` are all enabled, and `requireAuth` is off. Pass any flag explicitly to override it. MPT capability flags are **permanent** once the issuance exists. +{% /admonition %} + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Token.issue`, the `intent` (`MptIssueIntent`) carries: + +| Field | Type | Description | +| --- | --- | --- | +| `mptIssuanceId` | `string` | The id of the newly created MPT issuance. | + +## Underlying XRPL transactor + +Builds and submits a single [MPTokenIssuanceCreate](https://xrpl.org/docs/references/protocol/transactions/types/mptokenissuancecreate) transaction. + +## Example + +```ts +const { intent } = await client.token.issue({ + metadata: { + ticker: 'TBILL', + name: 'Acme T-Bill Token', + icon: 'https://acme.example/icon.png', + asset_class: 'rwa', + asset_subclass: 'treasury', + issuer_name: 'Acme Inc', + }, +}) + +console.log(intent.mptIssuanceId) +``` diff --git a/docs/simpleXRPL/references/verticals/token/list.md b/docs/simpleXRPL/references/verticals/token/list.md new file mode 100644 index 00000000..ccf87acb --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/list.md @@ -0,0 +1,59 @@ +--- +seo: + description: Token.list lists the MPTs an account holds or issued. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# token.list() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L79) + +List the MPTs an account holds or issued. + +## Signature + +```ts +token.list( + params?: TokenListParams +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `role` | `'holder' \| 'issuer'` | No | List tokens the account holds or issued. Defaults to tokens held if ommitted. | +| `account` | `string` | No | The account to query. Defaults to the primary signer's account. | + +## Returns + +Resolves to a `TokenListResult`, where `tokens[i]` corresponds to `data[i]`: + +| Field | Type | Description | +| --- | --- | --- | +| `tokens` | `readonly string[]` | The MPT issuance id of each token. | +| `data` | `readonly TokenListEntry[]` | The shaped entries. | + +### TokenListEntry + +| Field | Type | Description | +| --- | --- | --- | +| `tokenID` | `string` | The MPT issuance id. | +| `balance` | `string` _(optional)_ | The account's balance (present for `role: 'holder'`). | +| `issuance` | `TokenData` _(optional)_ | The full issuance snapshot (present for `role: 'issuer'`). See [token.retrieve](retrieve.md#tokendata) for `TokenData`. | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [account_objects](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/account-methods/account_objects). + +## Example + +```ts +const { data } = await client.token.list({ role: 'holder' }) + +for (const entry of data) { + console.log(entry.tokenID, entry.balance) +} +``` diff --git a/docs/simpleXRPL/references/verticals/token/listOffers.md b/docs/simpleXRPL/references/verticals/token/listOffers.md new file mode 100644 index 00000000..83d64d6d --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/listOffers.md @@ -0,0 +1,61 @@ +--- +seo: + description: Token.listOffers lists the open DEX offers placed by an account. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# token.listOffers() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L89) + +List the open DEX offers placed by an account. + +## Signature + +```ts +token.listOffers( + params?: TokenListOffersParams, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `account` | `string` | No | The account whose offers to list. Defaults to the primary signer's account. | + +## Returns + +Resolves to a `ListOffersResult`: + +| Field | Type | Description | +| --- | --- | --- | +| `data` | `readonly OfferSummary[]` | The shaped open offers. | + +### OfferSummary + +Each offer mirrors the `createOffer` / `buyOffer` / `sellOffer` input format, so it's composable back into those write verbs. + +| Field | Type | Description | +| --- | --- | --- | +| `offerSequence` | `number` | The offer's sequence number (pass to `cancelOffer`). | +| `amount` | `number` | The quantity of the base asset being traded. | +| `price` | `IOUOfferPrice` | What is paid/received for it, in offer-price form. | +| `orderType` | `'limit' \| 'passive'` | Resting offers are `limit`, or `passive` when the passive flag is set. | +| `type` | `'buy' \| 'sell'` | Whether the offer buys or sells the base asset. | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [account_offers](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/account-methods/account_offers). + +## Example + +```ts +const { data } = await client.token.listOffers() + +for (const offer of data) { + console.log(offer.offerSequence, offer.type, offer.amount) +} +``` diff --git a/docs/simpleXRPL/references/verticals/token/lock.md b/docs/simpleXRPL/references/verticals/token/lock.md new file mode 100644 index 00000000..6b499513 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/lock.md @@ -0,0 +1,60 @@ +--- +seo: + description: Token.lock locks an MPT issuance or a specific holder's balance via an MPTokenIssuanceSet transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.lock() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L211) + +Lock an MPT issuance, or a specific holder's balance when `holder` is given. + +## Signature + +```ts +token.lock( + params: MptLockParams, + options?: TokenWriteOptions, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `mptIssuanceId` | `string` | Yes | The MPT issuance id. | +| `holder` | `string` | No | A specific holder to lock. Omit to lock the whole issuance. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult<{ mptIssuanceId: string; locked: boolean }>`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Token.lock`, the `intent` carries: + +| Field | Type | Description | +| --- | --- | --- | +| `mptIssuanceId` | `string` | The MPT issuance id that was locked. | +| `locked` | `boolean` | The resulting lock state (`true`). | + +## Underlying XRPL transactor + +Builds and submits a single [MPTokenIssuanceSet](https://xrpl.org/docs/references/protocol/transactions/types/mptokenissuanceset) transaction with the lock flag set. + +## Example + +```ts +await client.token.lock({ + mptIssuanceId: '005C...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/token/retrieve.md b/docs/simpleXRPL/references/verticals/token/retrieve.md new file mode 100644 index 00000000..58786884 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/retrieve.md @@ -0,0 +1,63 @@ +--- +seo: + description: Token.retrieve reads a single MPT issuance by id, with flags and XLS-89 metadata decoded. Read-only. +labels: + - simpleXRPL + - SDK +--- + +# token.retrieve() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L67) + +Retrieve a single MPT issuance by id (point-in-time), with flags decoded to booleans and XLS-89 metadata decoded. + +## Signature + +```ts +token.retrieve( + params: TokenRetrieveParams, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `mptIssuanceId` | `string` | Yes | The MPT issuance id to fetch. | + +## Returns + +Resolves to a `TokenRetrieveResult`: + +| Field | Type | Description | +| --- | --- | --- | +| `tokenID` | `string` | The queried MPT issuance id. | +| `data` | `TokenData \| undefined` | The issuance snapshot, or `undefined` if no such issuance exists. | + +### TokenData + +| Field | Type | Description | +| --- | --- | --- | +| `tokenID` | `string` | The MPT issuance id. | +| `issuer` | `string` | The issuer r-address. | +| `assetScale` | `number` | Decimal places between display value and base units. | +| `maximumAmount` | `string` _(optional)_ | Maximum issuable amount (base units), if capped. | +| `outstandingAmount` | `string` | Amount currently in circulation (base units). | +| `transferFee` | `number` | Secondary-transfer fee, as a percentage. | +| `flags` | `MptFlags` | Capability flags decoded to booleans: `canLock`, `requireAuth`, `canEscrow`, `canTrade`, `canTransfer`, `canClawback`. | +| `metadata` | `MPTokenMetadata` _(optional)_ | Decoded XLS-89 metadata, if present and well-formed. | + +## Underlying XRPL request + +Read-only — no signer is required and nothing is submitted. Queries the ledger with [ledger_entry](https://xrpl.org/docs/references/http-websocket-apis/public-api-methods/ledger-methods/ledger_entry). + +## Example + +```ts +const { data } = await client.token.retrieve({ + mptIssuanceId: '005C...', +}) + +console.log(data?.outstandingAmount) +``` diff --git a/docs/simpleXRPL/references/verticals/token/revokeHolder.md b/docs/simpleXRPL/references/verticals/token/revokeHolder.md new file mode 100644 index 00000000..70f462bc --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/revokeHolder.md @@ -0,0 +1,60 @@ +--- +seo: + description: Token.revokeHolder lets an issuer revoke a specific holder's permission to hold an MPT via an MPTokenAuthorize transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.revokeHolder() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L197) + +As the issuer, revoke a specific holder's permission to hold this MPT. + +## Signature + +```ts +token.revokeHolder( + params: MptHolderParams, + options?: TokenWriteOptions, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `mptIssuanceId` | `string` | Yes | The MPT issuance id. | +| `holder` | `string` | Yes | The r-address of the holder to revoke. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult<{ mptIssuanceId: string }>`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Token.revokeHolder`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `mptIssuanceId` | `string` | The MPT issuance id the holder was revoked on. | + +## Underlying XRPL transactor + +Builds and submits a single [MPTokenAuthorize](https://xrpl.org/docs/references/protocol/transactions/types/mptokenauthorize) transaction naming the holder, with the unauthorize flag set. + +## Example + +```ts +await client.token.revokeHolder({ + mptIssuanceId: '005C...', + holder: 'rHolder...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/token/transfer.md b/docs/simpleXRPL/references/verticals/token/transfer.md new file mode 100644 index 00000000..02f6158e --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/transfer.md @@ -0,0 +1,63 @@ +--- +seo: + description: Token.transfer sends MPT units to another account via a Payment transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.transfer() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L266) + +Send an MPT amount to another account. + +## Signature + +```ts +token.transfer( + params: TokenTransferParams, + options?: TokenWriteOptions, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `to` | `string` | Yes | Destination r-address. | +| `amount` | `Amount` | Yes | The MPT amount to send; its asset must be an MPT (build it with `mpt()`). | + +{% raw-partial file="/docs/_snippets/simplexrpl-amount.md" /%} + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult<{ to: string; amount: string }>`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Token.transfer`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `to` | `string` | Destination r-address. | +| `amount` | `string` | The amount sent, as a decimal string. | + +## Underlying XRPL transactor + +Builds and submits a single [Payment](https://xrpl.org/docs/references/protocol/transactions/types/payment) transaction. Throws an `IntentValidationError` if `amount`'s asset is not an MPT — use [XRP.transfer](../xrp/transfer.md) for XRP. + +## Example + +```ts +await client.token.transfer({ + to: 'rHolder...', + amount: { asset: mpt('005C...'), value: '100' }, +}) +``` diff --git a/docs/simpleXRPL/references/verticals/token/unauthorize.md b/docs/simpleXRPL/references/verticals/token/unauthorize.md new file mode 100644 index 00000000..fbe230b2 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/unauthorize.md @@ -0,0 +1,58 @@ +--- +seo: + description: Token.unauthorize opts the calling account out of holding an MPT issuance via an MPTokenAuthorize transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.unauthorize() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L169) + +Opt the calling account out of holding an MPT issuance. The account's balance must be `0`. + +## Signature + +```ts +token.unauthorize( + params: MptAuthorizeParams, + options?: TokenWriteOptions, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `mptIssuanceId` | `string` | Yes | The MPT issuance id to opt out of. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult<{ mptIssuanceId: string }>`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Token.unauthorize`, the `intent` echoes: + +| Field | Type | Description | +| --- | --- | --- | +| `mptIssuanceId` | `string` | The MPT issuance id that was deauthorized. | + +## Underlying XRPL transactor + +Builds and submits a single [MPTokenAuthorize](https://xrpl.org/docs/references/protocol/transactions/types/mptokenauthorize) transaction, with the unauthorize flag set. + +## Example + +```ts +await client.token.unauthorize({ + mptIssuanceId: '005C...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/token/unlock.md b/docs/simpleXRPL/references/verticals/token/unlock.md new file mode 100644 index 00000000..8613616d --- /dev/null +++ b/docs/simpleXRPL/references/verticals/token/unlock.md @@ -0,0 +1,60 @@ +--- +seo: + description: Token.unlock unlocks an MPT issuance or a specific holder's balance via an MPTokenIssuanceSet transaction. +labels: + - simpleXRPL + - SDK +--- + +# token.unlock() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/token.ts#L225) + +Unlock a previously locked MPT issuance, or a specific holder's balance when `holder` is given. + +## Signature + +```ts +token.unlock( + params: MptLockParams, + options?: TokenWriteOptions, +): Promise +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `mptIssuanceId` | `string` | Yes | The MPT issuance id. | +| `holder` | `string` | No | A specific holder to unlock. Omit to unlock the whole issuance. | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult<{ mptIssuanceId: string; locked: boolean }>`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `Token.unlock`, the `intent` carries: + +| Field | Type | Description | +| --- | --- | --- | +| `mptIssuanceId` | `string` | The MPT issuance id that was unlocked. | +| `locked` | `boolean` | The resulting lock state (`false`). | + +## Underlying XRPL transactor + +Builds and submits a single [MPTokenIssuanceSet](https://xrpl.org/docs/references/protocol/transactions/types/mptokenissuanceset) transaction with the unlock flag set. + +## Example + +```ts +await client.token.unlock({ + mptIssuanceId: '005C...', +}) +``` diff --git a/docs/simpleXRPL/references/verticals/xrp/index.md b/docs/simpleXRPL/references/verticals/xrp/index.md new file mode 100644 index 00000000..5ab7d437 --- /dev/null +++ b/docs/simpleXRPL/references/verticals/xrp/index.md @@ -0,0 +1,15 @@ +--- +seo: + description: The XRP vertical in simpleXRPL handles native XRP value transfers. +labels: + - simpleXRPL + - SDK +--- + +# XRP + +The `XRP` vertical handles native XRP value transfers. + +| Method | Description | +| --- | --- | +| [transfer](transfer.md) | Send native XRP from one account to another. | diff --git a/docs/simpleXRPL/references/verticals/xrp/transfer.md b/docs/simpleXRPL/references/verticals/xrp/transfer.md new file mode 100644 index 00000000..9748faae --- /dev/null +++ b/docs/simpleXRPL/references/verticals/xrp/transfer.md @@ -0,0 +1,63 @@ +--- +seo: + description: XRP.transfer sends native XRP from one account to another via a Payment transaction. +labels: + - simpleXRPL + - SDK +--- + +# xrp.transfer() + +[[Source]](https://github.com/ripple/simpleXRPL/blob/50619258cf753008e8a185eaeb3ceca489e5998a/src/verticals/xrp.ts#L67) + +Send native XRP from one account to another. + +## Signature + +```ts +xrp.transfer( + params: XrpTransferParams, + options?: XrpTransferOptions, +): Promise> +``` + +## Parameters + +| Parameter | Type | Required | Description | +| --- | --- | --- | --- | +| `to` | `string` | Yes | Destination account XRPL address. | +| `amount` | `string` | Yes | Amount to send, as a decimal string in XRP (e.g. `'10'`, `'0.25'`). | + +## Options + +{% raw-partial file="/docs/_snippets/simplexrpl-write-options.md" /%} + +## Returns + +Resolves to a `SubmissionResult`. + +{% raw-partial file="/docs/_snippets/simplexrpl-response-fields.md" /%} + +### Return fields + +For `XRP.transfer`, the `intent` (`XrpTransferIntent`) carries: + +| Field | Type | Description | +| --- | --- | --- | +| `to` | `string` | Destination r-address. | +| `amount` | `string` | Amount sent, in XRP. | + +## Underlying XRPL transactor + +Builds and submits a single [Payment](https://xrpl.org/docs/references/protocol/transactions/types/payment) transaction. + +## Example + +```ts +const result = await client.xrp.transfer({ + to: 'rDestination...', + amount: '10', +}) + +console.log(result.txHash) +``` diff --git a/docs/simpleXRPL/tutorials/create-permissioned-domain.md b/docs/simpleXRPL/tutorials/create-permissioned-domain.md new file mode 100644 index 00000000..dcc61b6f --- /dev/null +++ b/docs/simpleXRPL/tutorials/create-permissioned-domain.md @@ -0,0 +1,75 @@ +--- +seo: + description: Set up a permissioned domain that restricts participation to credential holders, then scope DEX offers to it. +labels: + - simpleXRPL + - SDK +--- + +# Create A Permissioned Domain + +A permissioned domain restricts who can participate based on the credentials they hold. Create the domain with the credentials it accepts, then scope DEX offers to it with `domainID`. + +```ts +/** + * Set up a permissioned domain and trade inside it. + * + * A permissioned domain restricts who can participate based on the credentials + * they hold. Create the domain with the credentials it accepts, then scope DEX + * offers to it with `domainID`. + */ +import { LocalSigner, SimpleXRPL } from 'simplexrpl' + +const client = await SimpleXRPL.init({ + xrpldUrl: 'wss://s.altnet.rippletest.net:51233', + signers: [LocalSigner.fromEnv()], +}) + +// 1. Create the domain, listing the credentials it accepts (issuer + type). +const domain = await client.domain.create({ + credList: [ + { issuer: 'rKycIssuer0000000000000000000000000', credType: 'KYC' }, + { issuer: 'rAccreditation000000000000000000000', credType: 'ACCREDITED' }, + ], +}) +const domainID = domain.intent.domainID +console.log('permissioned domain:', domainID) + +// 2. Update the accepted credentials later if the policy changes. +await client.domain.setCredentials({ + domain: domainID, + credList: [ + { issuer: 'rKycIssuer0000000000000000000000000', credType: 'KYC' }, + ], +}) + +// 3. Place a domain-scoped DEX offer. With `domainID` set, the offer defaults +// to hybrid (also crosses the open DEX) unless `hybrid: false` is passed. +await client.iou.sellOffer({ + ticker: 'USD', + amount: 100, + orderType: 'limit', + price: { currency: 'XRP', amount: 50 }, + domainID, + hybrid: false, // permissioned-only: do not touch the open DEX +}) + +// 4. Read it back (no signer required). `retrieve` resolves a domain by id and +// returns its owner and accepted-credential list (decoded from hex); `list` +// returns every domain owned by an account (defaults to the primary). +const read = await client.domain.retrieve({ domainID }) +console.log('accepts:', read.data?.credList) + +const owned = await client.domain.list() +console.log('owned domains:', owned.domains) + +await client.disconnect() +``` + +## See Also + +- [domain.create()](../references/verticals/domain/create.md) +- [domain.setCredentials()](../references/verticals/domain/setCredentials.md) +- [domain.retrieve()](../references/verticals/domain/retrieve.md) +- [domain.list()](../references/verticals/domain/list.md) +- [iou.sellOffer()](../references/verticals/iou/sellOffer.md) diff --git a/docs/simpleXRPL/tutorials/cross-custodian-workflows.md b/docs/simpleXRPL/tutorials/cross-custodian-workflows.md new file mode 100644 index 00000000..99019860 --- /dev/null +++ b/docs/simpleXRPL/tutorials/cross-custodian-workflows.md @@ -0,0 +1,71 @@ +--- +seo: + description: Drive accounts held by different custodians from a single client, using per-call routing or an ordered multi-step sequence. +labels: + - simpleXRPL + - SDK +--- + +# Run A Workflow Across Custodians + +A single client can drive accounts held by different connectors. Sequence work across them either with per-call `from` routing (the common case) or with `runMultiStep`, which commits an ordered (transaction, account) sequence — steps that can target different custodians — from one call site. + +```ts +/** + * Run a workflow across two custodians. + * + * A single client can drive accounts held by different connectors: each vertical + * operation routes automatically to the custodian that owns the account it acts on — + * named via `from`, or the primary signer by default. + */ +import { PalisadeCustody, RippleCustody, SimpleXRPL } from 'simplexrpl' + +// A common institutional split: the issuer is held in Ripple Custody (governed +// approvals), the distribution/hot wallet in Palisade. One client drives both. +// Config comes from the environment / your secrets manager. +const custody = await RippleCustody.fromEnv({ + primary: process.env.RIPPLE_CUSTODY_PRIMARY ?? '', +}) +const palisade = await PalisadeCustody.create({ + baseUrl: 'https://api.sandbox.palisade.co', // sandbox (TESTNET data) + // Two credentials: a wallet-read one (discovery) and a transactions one. + credentials: { + wallets: { + clientId: process.env.PALISADE_WALLETS_CLIENT_ID ?? '', + clientSecret: process.env.PALISADE_WALLETS_CLIENT_SECRET ?? '', + }, + transactions: { + clientId: process.env.PALISADE_TX_CLIENT_ID ?? '', + clientSecret: process.env.PALISADE_TX_CLIENT_SECRET ?? '', + }, + }, + primary: { + vaultId: process.env.PALISADE_VAULT_ID ?? '', + walletId: process.env.PALISADE_WALLET_ID ?? '', + }, +}) + +const client = await SimpleXRPL.init({ + xrpldUrl: 'wss://s.altnet.rippletest.net:51233', // XRPL Testnet + signers: [custody, palisade], +}) + +// The distribution/hot wallet on the Palisade connector. +const hotWallet = client.resolveAccount(palisade.primary.address) + +// Each operation targets a different custodian. Issue an IOU as the Custody issuer +// (the primary signer), then pay out from the Palisade hot wallet via `from` — +// the client routes each call to the connector that owns the account. +await client.iou.issue({ ticker: 'USD' }) +await client.xrp.transfer( + { to: 'rBeneficiary00000000000000000000000', amount: '25' }, + { from: hotWallet.address }, +) + +await client.disconnect() +``` + +## See Also + +- [iou.issue()](../references/verticals/iou/issue.md) +- [xrp.transfer()](../references/verticals/xrp/transfer.md) diff --git a/docs/simpleXRPL/tutorials/external-signer.md b/docs/simpleXRPL/tutorials/external-signer.md new file mode 100644 index 00000000..a1445b38 --- /dev/null +++ b/docs/simpleXRPL/tutorials/external-signer.md @@ -0,0 +1,106 @@ +--- +seo: + description: Implement the ExternalSignerPort seam end to end with a mock signer, and switch between secp256k1 and ed25519. +labels: + - simpleXRPL + - SDK +--- + +# Implement An External Signer + +The `ExternalSignerPort` seam lets you plug in your own signer. This sample implements it with an in-process key so it actually signs and submits against a mock ledger, and shows how to switch between the secp256k1 and ed25519 schemes. In production you swap the mock for a KMS or HSM signer — nothing else changes. + +```ts +/** + * External signing end to end — and switching algorithms. + * + * The `ExternalSignerPort` seam covers both XRPL signature schemes; the SDK + * routes the crypto by algorithm (secp256k1: SHA-512Half digest → low-S → DER; + * ed25519: sign the message directly). The procedure below is identical for + * either — you just pass a different port. + * + * As shipped this file is illustrative: the in-process demo signers at the + * bottom are commented out. Uncomment them (or plug in your own KMS/HSM-backed + * `ExternalSignerPort`) for the snippet to run. + */ +import { ExternalSigner, SimpleXRPL } from 'simplexrpl' +import type { Ed25519SignerPort, Secp256k1SignerPort } from 'simplexrpl' + +import { inMemoryLedger } from './mocks.js' + +// === What you write with simpleXRPL === +// Bind your external signer, then build → sign → submit. The pipeline is the +// same whether the signer is secp256k1 or ed25519. +async function signAndSubmit( + signer: Secp256k1SignerPort | Ed25519SignerPort, + label: string, +): Promise { + const custody = await ExternalSigner.create({ signer }) + const client = await SimpleXRPL.init({ + xrpldUrl: 'wss://s.altnet.rippletest.net:51233', // XRPL Testnet + signers: [custody], + ledger: inMemoryLedger(), // omit in production to use the live XRPL connection + }) + const result = await client.xrp.transfer({ + to: client.account.create().address, + amount: '10', + }) + console.log( + `${label}: account ${custody.primary.address} signed & submitted ` + + `(source=${result.source}, hash=${result.txHash})`, + ) + await client.disconnect() +} + +// === Demo signers — uncomment to run, or replace with your own KMS/HSM === +// These use in-process keys via `@noble/curves` so the file runs offline; a +// real port delegates the digest/message to your KMS or HSM. Switch algorithms +// by swapping the port — `signAndSubmit` above doesn't change. +// +// import { ed25519 } from '@noble/curves/ed25519' +// import { secp256k1 } from '@noble/curves/secp256k1' +// +// function mockSecp256k1(privHex: string): Secp256k1SignerPort { +// const priv = Buffer.from(privHex, 'hex') +// return { +// algorithm: 'secp256k1', +// publicKey: async (): Promise => +// Buffer.from(secp256k1.getPublicKey(priv, true)) +// .toString('hex') +// .toUpperCase(), +// signDigest: async (digest: Uint8Array) => { +// const sig = secp256k1.sign(digest, priv) +// return { r: sig.r, s: sig.s } +// }, +// } +// } +// +// function mockEd25519(privHex: string): Ed25519SignerPort { +// const priv = Buffer.from(privHex, 'hex') +// return { +// algorithm: 'ed25519', +// publicKey: async (): Promise => +// `ED${Buffer.from(ed25519.getPublicKey(priv)).toString('hex')}`.toUpperCase(), +// signMessage: async (message: Uint8Array): Promise => +// ed25519.sign(message, priv), +// } +// } +// +// await signAndSubmit( +// mockSecp256k1( +// 'c9537c5a2f3f7e1d4b6a8c0e2f4d6b8a1c3e5f7091b3d5f7a9c1e3050709b0d0f', +// ), +// 'secp256k1', +// ) +// await signAndSubmit( +// mockEd25519( +// '9d61b19deffebc3a6c1f6b2d7e5f8a0b1c2d3e4f5061728394a5b6c7d8e9f001', +// ), +// 'ed25519', +// ) +``` + +## See Also + +- [account.create()](../references/verticals/account/create.md) +- [xrp.transfer()](../references/verticals/xrp/transfer.md) diff --git a/docs/simpleXRPL/tutorials/implement-aws-kms-signer.md b/docs/simpleXRPL/tutorials/implement-aws-kms-signer.md new file mode 100644 index 00000000..e2b2ddc9 --- /dev/null +++ b/docs/simpleXRPL/tutorials/implement-aws-kms-signer.md @@ -0,0 +1,53 @@ +--- +seo: + description: Sign transactions with a secp256k1 key held in AWS KMS using the simplexrpl/aws-kms adapter; the private key never leaves KMS. +labels: + - simpleXRPL + - SDK +--- + +# Sign With AWS KMS + +`simpleXRPL` ships an [AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/overview.html) adapter as a subpath import (`simplexrpl/aws-kms`). The private key stays in KMS and never enters the process — the SDK hands KMS a digest and assembles the signature. + +```ts +/** + * Sign with a key held in AWS KMS. + * + * simpleXRPL ships an AWS KMS adapter as a subpath import. The private key + * stays in KMS and never enters the process: the SDK hands KMS a digest and + * assembles the signature. Requires the optional peer dependency + * `@aws-sdk/client-kms` and an `ECC_SECG_P256K1` (secp256k1) KMS key. + * + * Credentials come from the standard AWS chain (env vars, shared profile, or an + * instance/role). This drops into your app once those and the key id are set. + */ +import { AwsKmsSigner } from 'simplexrpl/aws-kms' +import { ExternalSigner, SimpleXRPL } from 'simplexrpl' + +// The KMS-backed signer. Its XRPL account is derived from the key's public key. +const signer = AwsKmsSigner.create({ + keyId: process.env.AWS_KMS_KEY_ID ?? '', + region: process.env.AWS_REGION ?? 'us-east-1', +}) +const custody = await ExternalSigner.create({ signer }) + +const client = await SimpleXRPL.init({ + xrpldUrl: 'wss://s.altnet.rippletest.net:51233', // XRPL Testnet + signers: [custody], +}) + +// The KMS account signs like any other connector — build, sign (in KMS), submit. +// Replace with a real, funded destination r-address. +const result = await client.xrp.transfer({ + to: 'rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe', + amount: '10', +}) +console.log('submitted via KMS-held key:', result.txHash) + +await client.disconnect() +``` + +## See Also + +- [xrp.transfer()](../references/verticals/xrp/transfer.md) diff --git a/docs/simpleXRPL/tutorials/implement-pkcs11-signer.md b/docs/simpleXRPL/tutorials/implement-pkcs11-signer.md new file mode 100644 index 00000000..5004aed6 --- /dev/null +++ b/docs/simpleXRPL/tutorials/implement-pkcs11-signer.md @@ -0,0 +1,115 @@ +--- +seo: + description: Implement the ExternalSignerPort seam against a PKCS#11 HSM — you provide the public key and digest signing; the SDK owns the XRPL crypto. +labels: + - simpleXRPL + - SDK +--- + +# Implement A PKCS#11 HSM Signer + +For an HSM, you implement the same `ExternalSignerPort` seam against your device: you provide only "give me the public key" and "sign this digest," and the SDK owns the XRPL crypto. HSM setups vary, so this is a reference to adapt rather than a drop-in. + +```ts +/** + * Bring-your-own HSM signer (PKCS#11). + * + * simpleXRPL ships an AWS KMS adapter (`simplexrpl/aws-kms`); for an HSM you + * implement the same `ExternalSignerPort` seam against your device. The SDK owns + * the XRPL crypto (SHA-512Half digest, low-S normalization, DER encoding); your + * port only provides "give me the public key" and "sign this digest". + * + * As shipped this file is illustrative: the PKCS#11 adapter and its in-process + * demo HSM at the bottom are commented out. Uncomment them (or wire the `Hsm` + * interface to your real PKCS#11 binding, e.g. `pkcs11js`) for the snippet to + * run. + */ +import { ExternalSigner, SimpleXRPL } from 'simplexrpl' +import type { Secp256k1SignerPort } from 'simplexrpl' + +import { inMemoryLedger } from './mocks.js' + +// === What you write with simpleXRPL === +// `signer` is your Secp256k1SignerPort backed by the HSM (see the adapter +// below). `client.xrp`, `client.iou`, etc. now sign through the HSM — the +// private key never leaves the device. Build → sign (in the HSM) → submit. +async function transferWithHsm(signer: Secp256k1SignerPort): Promise { + const custody = await ExternalSigner.create({ signer }) + const client = await SimpleXRPL.init({ + xrpldUrl: 'wss://s.altnet.rippletest.net:51233', // XRPL Testnet + signers: [custody], + ledger: inMemoryLedger(), // omit in production to use the live XRPL connection + }) + const result = await client.xrp.transfer({ + to: client.account.create().address, + amount: '10', + }) + console.log( + `HSM account ${custody.primary.address} signed & submitted ` + + `(source=${result.source}, hash=${result.txHash})`, + ) + await client.disconnect() +} + +// === Bring-your-own HSM (PKCS#11) — uncomment to run, or wire your device === +// HSM setups vary (slot, PIN, key label, vendor library), so this is a +// reference to adapt. `demoHsm()` (from ./mocks) is an in-process stand-in so +// the file runs offline; swap it for a real PKCS#11 binding. The SDK owns low-S +// normalization + DER encoding; your port returns the raw `r‖s` scalars. +// +// import type { EcdsaSignature } from 'simplexrpl' +// import { demoHsm } from './mocks.js' +// +// // secp256k1 sizes: 32-byte scalars, 65-byte uncompressed point (0x04‖X‖Y). +// const SCALAR_BYTES = 32 +// const POINT_BYTES = 65 +// const COMPRESSED_EVEN = 0x02 +// const COMPRESSED_ODD = 0x03 +// const EVEN = 2 +// +// /** The narrow slice of your HSM the signer needs (PKCS#11, ECDSA secp256k1). */ +// interface Hsm { +// // CKA_EC_POINT — DER OCTET STRING wrapping the uncompressed point 0x04‖X‖Y. +// readonly ecPoint: () => Promise +// // C_Sign with CKM_ECDSA (NOT CKM_ECDSA_SHA256 — the digest is pre-hashed); +// // returns the raw 64-byte r‖s. +// readonly signDigest: (digest: Uint8Array) => Promise +// } +// +// /** Strip the DER wrapper; the uncompressed point is the trailing 65 bytes. */ +// function uncompressedPoint(ecPoint: Uint8Array): Buffer { +// return Buffer.from(ecPoint).subarray(-POINT_BYTES) +// } +// +// /** An ExternalSignerPort backed by a PKCS#11 HSM. */ +// class Pkcs11Signer implements Secp256k1SignerPort { +// public readonly algorithm = 'secp256k1' +// public constructor(private readonly hsm: Hsm) {} +// +// public async publicKey(): Promise { +// const point = uncompressedPoint(await this.hsm.ecPoint()) +// const x = point.subarray(1, 1 + SCALAR_BYTES) +// const y = point.subarray(1 + SCALAR_BYTES) +// const prefix = +// y[y.length - 1] % EVEN === 0 ? COMPRESSED_EVEN : COMPRESSED_ODD +// return Buffer.concat([Buffer.from([prefix]), x]) +// .toString('hex') +// .toUpperCase() +// } +// +// public async signDigest(digest: Uint8Array): Promise { +// const raw = Buffer.from(await this.hsm.signDigest(digest)) +// return { +// r: BigInt(`0x${raw.subarray(0, SCALAR_BYTES).toString('hex')}`), +// s: BigInt(`0x${raw.subarray(SCALAR_BYTES).toString('hex')}`), +// } +// } +// } +// +// await transferWithHsm(new Pkcs11Signer(demoHsm())) +``` + +## See Also + +- [account.create()](../references/verticals/account/create.md) +- [xrp.transfer()](../references/verticals/xrp/transfer.md) diff --git a/docs/simpleXRPL/tutorials/issue-and-distribute-iou.md b/docs/simpleXRPL/tutorials/issue-and-distribute-iou.md new file mode 100644 index 00000000..6df930be --- /dev/null +++ b/docs/simpleXRPL/tutorials/issue-and-distribute-iou.md @@ -0,0 +1,86 @@ +--- +seo: + description: "Issue a trust line currency (IOU) and distribute it: bootstrap the issuer and hot wallet, then transfer the currency out." +labels: + - simpleXRPL + - SDK +--- + +# Issue And Distribute An IOU + +`issue` bootstraps the issuer and a hot wallet from the environment (the issuer enables rippling and the hot wallet extends a trust line). No value exists until `transfer` sends the currency out. Every verb acts as the issuer, selected via `from`. The XRP Ledger supports two token standards (MPT and trust line tokens). MPTs have been designed for greater efficiency and ease of use based on lessons learned from trust line tokens, however there are some cases where you may prefer trust line tokens. See: [Which Fungible Token Type to Use](https://xrpl.org/docs/concepts/tokens/fungible-tokens#which-fungible-token-type-to-use). + +```ts +/** + * Issue and distribute an IOU (trust-line currency) with Palisade-held accounts. + * + * `issue` sets up the trust line: the issuer enables rippling (`AccountSet`) and + * the hot wallet extends trust (`TrustSet`). Both are Palisade wallets here — + * pass the hot wallet via `holder`, and the issuer defaults to the primary + * signer. No value exists yet — `transfer` sends the currency out. Every + * operation acts as the issuer, selected via `from` (default: the primary). + */ +import { PalisadeCustody, SimpleXRPL } from 'simplexrpl' + +// The issuer wallet, held in Palisade (the primary signer). Palisade needs two +// credentials: a wallet-read one (discovery) and a transactions one (signing). +const palisade = await PalisadeCustody.create({ + baseUrl: 'https://api.sandbox.palisade.co', // sandbox (TESTNET data) + credentials: { + wallets: { + clientId: process.env.PALISADE_WALLETS_CLIENT_ID ?? '', + clientSecret: process.env.PALISADE_WALLETS_CLIENT_SECRET ?? '', + }, + transactions: { + clientId: process.env.PALISADE_TX_CLIENT_ID ?? '', + clientSecret: process.env.PALISADE_TX_CLIENT_SECRET ?? '', + }, + }, + primary: { + vaultId: process.env.PALISADE_VAULT_ID ?? '', + walletId: process.env.PALISADE_WALLET_ID ?? '', + }, +}) + +const client = await SimpleXRPL.init({ + xrpldUrl: 'wss://s.altnet.rippletest.net:51233', // XRPL Testnet + signers: [palisade], +}) + +// The hot wallet: a second Palisade wallet in the same org. It extends trust to +// the issuer, and both accounts are signed by Palisade. +const hotWallet = process.env.PALISADE_HOLDER_ADDRESS ?? '' + +// 1. Issue: AccountSet on the issuer (the primary) + a max-limit TrustSet on the +// hot wallet. Returns the IOU id, e.g. "USD.rIssuer...". +const issued = await client.iou.issue({ ticker: 'USD', holder: hotWallet }) +console.log('issued', issued.intent.iouID) + +// 2. Distribute: send 1,000 USD from the issuer to the hot wallet, which now +// trusts it. Other holders extend their own trust line first. +await client.iou.transfer({ + ticker: 'USD', + destination: hotWallet, + amount: 1000, +}) + +// 3. Read it back (no signer required): the hot wallet's shaped USD trust line. +// The issuer is the second half of the iouID ("USD.rIssuer..."). +const [, issuer] = issued.intent.iouID.split('.') +const line = await client.iou.retrieve({ + ticker: 'USD', + issuer, + account: hotWallet, +}) +console.log('hot wallet balance:', line.data?.balance ?? '0') + +await client.disconnect() +``` + +## See Also + +- [iou.issue()](../references/verticals/iou/issue.md) +- [iou.transfer()](../references/verticals/iou/transfer.md) +- [iou.authorize()](../references/verticals/iou/authorize.md) +- [iou.retrieve()](../references/verticals/iou/retrieve.md) +- [iou.list()](../references/verticals/iou/list.md) diff --git a/docs/simpleXRPL/tutorials/issue-rwa-as-mpt.md b/docs/simpleXRPL/tutorials/issue-rwa-as-mpt.md new file mode 100644 index 00000000..fbba0a7f --- /dev/null +++ b/docs/simpleXRPL/tutorials/issue-rwa-as-mpt.md @@ -0,0 +1,68 @@ +--- +seo: + description: Issue a Real-World Asset as a Multi-Purpose Token (MPT) through Ripple Custody, with XLS-89 metadata validated before submission. +labels: + - simpleXRPL + - SDK +--- + +# Issue An RWA As An MPT + +Real-World Assets are issued as Multi-Purpose Tokens (MPTs) via the `token` vertical. Here the issuer is a Ripple Custody account, so Custody signs and submits the issuance as one governed action, with XLS-89 metadata validated before submission. The XRP Ledger supports to token standards (MPT and trust line tokens). MPTs have been designed for greater efficiency and ease of use based on lessons learned from trust line tokens, however there are some cases where you may prefer trust line tokens. See: [Which Fungible Token Type to Use](https://xrpl.org/docs/concepts/tokens/fungible-tokens#which-fungible-token-type-to-use). + +```ts +/** + * Issue a Real-World Asset (RWA) through Ripple Custody. + * + * RWAs are issued as Multi-Purpose Tokens (MPTs) via the `token` vertical. + * Metadata follows the XLS-89 standard and is validated before submission + * (`asset_class: 'rwa'` requires an `asset_subclass`). Here the issuer is a + * Ripple Custody account: Custody signs and submits the issuance as one + * governed action, subject to the domain's approval policy. `MPTokenIssuanceCreate` + * is native to Ripple Custody, so it flows through the governed native path. + */ +import { RippleCustody, SimpleXRPL } from 'simplexrpl' + +// The Custody-held issuer account; Custody governs every write it signs. +const ISSUER_ADDRESS = process.env.RIPPLE_CUSTODY_PRIMARY ?? '' + +// Config (gateway, token endpoint, domain, intent-author key) comes from +// `RIPPLE_CUSTODY_*` environment variables via `fromEnv`. +const custody = await RippleCustody.fromEnv({ primary: ISSUER_ADDRESS }) + +const client = await SimpleXRPL.init({ + xrpldUrl: 'wss://s.altnet.rippletest.net:51233', // XRPL Testnet + signers: [custody], +}) + +// Metadata is the only required input. The issuer is the primary signer (the +// Custody account), and everything else — assetScale, transfer fee, and the +// capability flags (clawback, transfer, …) — is left at its SDK default. +const result = await client.token.issue({ + metadata: { + ticker: 'TBILL', + name: 'Acme 3-Month T-Bill', + icon: 'https://acme.example/tbill.png', + asset_class: 'rwa', + asset_subclass: 'treasury', + issuer_name: 'Acme Capital', + }, +}) +console.log('issued MPT:', result.intent.mptIssuanceId) + +// Read the issuance back (no signer required): flags are decoded to booleans, +// the transfer fee to a percentage, and XLS-89 metadata is parsed. +const token = await client.token.retrieve({ + mptIssuanceId: result.intent.mptIssuanceId, +}) +console.log('transfer fee (%):', token.data?.transferFee) +console.log('can claw back:', token.data?.flags.canClawback) +console.log('metadata:', token.data?.metadata?.name) + +await client.disconnect() +``` + +## See Also + +- [token.issue()](../references/verticals/token/issue.md) +- [token.retrieve()](../references/verticals/token/retrieve.md) diff --git a/docs/simpleXRPL/tutorials/place-dex-order.md b/docs/simpleXRPL/tutorials/place-dex-order.md new file mode 100644 index 00000000..5680a24e --- /dev/null +++ b/docs/simpleXRPL/tutorials/place-dex-order.md @@ -0,0 +1,90 @@ +--- +seo: + description: Place buy and sell orders on the XRP Ledger DEX with the iou and token verticals, using familiar order types. +labels: + - simpleXRPL + - SDK +--- + +# Place A DEX Order + +The `iou` vertical places orders to buy or sell an issued currency; the `token` vertical places generic offers between any two DEX-tradeable assets (XRP or IOU). The order type controls how the offer is worked. + +```ts +/** + * Place an order on the DEX. + * + * The `iou` vertical places orders to buy or sell an issued currency; the + * `token` vertical places generic offers between any two DEX-tradeable assets + * (XRP or IOU). Order type controls how the offer is worked. + */ +import { iou, LocalSigner, SimpleXRPL, XRP_ASSET } from 'simplexrpl' + +const client = await SimpleXRPL.init({ + xrpldUrl: 'wss://s.altnet.rippletest.net:51233', + signers: [LocalSigner.fromEnv()], +}) + +// --- Via the IOU vertical: sell 100 USD for 50 XRP ------------------------- +// orderType: 'limit' rests on the book; 'market' = immediate-or-cancel; +// 'fok' = fill-or-kill; 'passive' = rest without crossing. +const sell = await client.iou.sellOffer({ + ticker: 'USD', + amount: 100, + orderType: 'limit', + price: { currency: 'XRP', amount: 50 }, +}) +console.log('sell offer submitted:', sell.txHash) + +// Buy 100 USD, paying in another IOU (EUR): +await client.iou.buyOffer({ + ticker: 'USD', + amount: 100, + orderType: 'fok', + price: { + ticker: 'EUR', + issuer: 'rEurIssuer000000000000000000000000', + amount: 90, + }, +}) + +// Read your resting offers back (no signer required) — each is shaped with its +// sequence, amount, price, and buy/sell type, ready to compose or cancel. +const mine = await client.account.listOffers() +for (const offer of mine.data) { + console.log(offer.type, offer.amount, '@', offer.price) +} + +// Or read the whole USD order book (both sides), regardless of who placed them: +const book = await client.iou.listOffers({ + ticker: 'USD', + issuer: 'rIssuer00000000000000000000000000000', +}) +console.log('resting USD offers:', book.data.length) + +// Cancel a resting offer by its sequence number — here, the first one read back: +if (mine.data.length > 0) { + await client.iou.cancelOffer({ offerSequence: mine.data[0].offerSequence }) +} + +// --- Via the token vertical: a generic XRP/IOU offer ----------------------- +await client.token.createOffer({ + takerGets: { asset: XRP_ASSET, value: '50' }, + takerPays: { + asset: iou('USD', 'rIssuer00000000000000000000000000000'), + value: '100', + }, + flags: { immediateOrCancel: true }, +}) + +await client.disconnect() +``` + +## See Also + +- [iou.buyOffer()](../references/verticals/iou/buyOffer.md) +- [iou.sellOffer()](../references/verticals/iou/sellOffer.md) +- [iou.cancelOffer()](../references/verticals/iou/cancelOffer.md) +- [iou.listOffers()](../references/verticals/iou/listOffers.md) +- [token.createOffer()](../references/verticals/token/createOffer.md) +- [account.listOffers()](../references/verticals/account/listOffers.md) diff --git a/index.page.tsx b/index.page.tsx index 7d57a23d..e638f919 100644 --- a/index.page.tsx +++ b/index.page.tsx @@ -21,7 +21,14 @@ export default function Page() { - + + + +

Integrate with your custodian and build on the XRPL.

+ +

Prepare and submit up to 8 transactions in a single batch.

diff --git a/redocly.yaml b/redocly.yaml index c3fc6b6e..34698fb8 100644 --- a/redocly.yaml +++ b/redocly.yaml @@ -14,12 +14,12 @@ redirects: $ref: redirects.yaml navbar: items: - - label: Home - page: index.page.tsx - label: Open Source Projects page: docs/index.md - label: Roadmap - page: ripplex-roadmap.md + page: ripplex-roadmap.md + - label: simpleXRPL + page: docs/simpleXRPL/index.md footer: items: - group: About diff --git a/sidebars.yaml b/sidebars.yaml index ff1d1c10..bc94add3 100644 --- a/sidebars.yaml +++ b/sidebars.yaml @@ -1,7 +1,156 @@ -- page: ripplex-roadmap.md - page: docs/index.md -- group: Prerelease Docs - expanded: true +- page: ripplex-roadmap.md +- group: simpleXRPL + page: docs/simpleXRPL/index.md + expanded: false + items: + - page: docs/simpleXRPL/get-started.md + - group: Tutorials + expanded: false + items: + - page: docs/simpleXRPL/tutorials/issue-rwa-as-mpt.md + - page: docs/simpleXRPL/tutorials/issue-and-distribute-iou.md + - page: docs/simpleXRPL/tutorials/place-dex-order.md + - page: docs/simpleXRPL/tutorials/create-permissioned-domain.md + - page: docs/simpleXRPL/tutorials/cross-custodian-workflows.md + - page: docs/simpleXRPL/tutorials/external-signer.md + - page: docs/simpleXRPL/tutorials/implement-aws-kms-signer.md + - page: docs/simpleXRPL/tutorials/implement-pkcs11-signer.md + - group: References + expanded: false + items: + - page: docs/simpleXRPL/references/client.md + - page: docs/simpleXRPL/references/types.md + - group: Connectors + page: docs/simpleXRPL/references/connectors/index.md + expanded: false + items: + - page: docs/simpleXRPL/references/connectors/local.md + - page: docs/simpleXRPL/references/connectors/external.md + - page: docs/simpleXRPL/references/connectors/ripple-custody.md + - page: docs/simpleXRPL/references/connectors/palisade.md + - page: docs/simpleXRPL/references/connectors/connector-routing.md + - group: Verticals + page: docs/simpleXRPL/references/verticals/index.md + expanded: false + items: + - group: XRP + page: docs/simpleXRPL/references/verticals/xrp/index.md + expanded: false + items: + - page: docs/simpleXRPL/references/verticals/xrp/transfer.md + label: transfer() + - group: Token + page: docs/simpleXRPL/references/verticals/token/index.md + expanded: false + items: + - page: docs/simpleXRPL/references/verticals/token/issue.md + label: issue() + - page: docs/simpleXRPL/references/verticals/token/transfer.md + label: transfer() + - page: docs/simpleXRPL/references/verticals/token/authorize.md + label: authorize() + - page: docs/simpleXRPL/references/verticals/token/unauthorize.md + label: unauthorize() + - page: docs/simpleXRPL/references/verticals/token/grantHolder.md + label: grantHolder() + - page: docs/simpleXRPL/references/verticals/token/revokeHolder.md + label: revokeHolder() + - page: docs/simpleXRPL/references/verticals/token/lock.md + label: lock() + - page: docs/simpleXRPL/references/verticals/token/unlock.md + label: unlock() + - page: docs/simpleXRPL/references/verticals/token/destroy.md + label: destroy() + - page: docs/simpleXRPL/references/verticals/token/createOffer.md + label: createOffer() + - page: docs/simpleXRPL/references/verticals/token/cancelOffer.md + label: cancelOffer() + - page: docs/simpleXRPL/references/verticals/token/retrieve.md + label: retrieve() + - page: docs/simpleXRPL/references/verticals/token/list.md + label: list() + - page: docs/simpleXRPL/references/verticals/token/listOffers.md + label: listOffers() + - group: IOU + page: docs/simpleXRPL/references/verticals/iou/index.md + expanded: false + items: + - page: docs/simpleXRPL/references/verticals/iou/issue.md + label: issue() + - page: docs/simpleXRPL/references/verticals/iou/transfer.md + label: transfer() + - page: docs/simpleXRPL/references/verticals/iou/authorize.md + label: authorize() + - page: docs/simpleXRPL/references/verticals/iou/lock.md + label: lock() + - page: docs/simpleXRPL/references/verticals/iou/unlock.md + label: unlock() + - page: docs/simpleXRPL/references/verticals/iou/clawback.md + label: clawback() + - page: docs/simpleXRPL/references/verticals/iou/buyOffer.md + label: buyOffer() + - page: docs/simpleXRPL/references/verticals/iou/sellOffer.md + label: sellOffer() + - page: docs/simpleXRPL/references/verticals/iou/cancelOffer.md + label: cancelOffer() + - page: docs/simpleXRPL/references/verticals/iou/retrieve.md + label: retrieve() + - page: docs/simpleXRPL/references/verticals/iou/list.md + label: list() + - page: docs/simpleXRPL/references/verticals/iou/listOffers.md + label: listOffers() + - group: Credential + page: docs/simpleXRPL/references/verticals/credential/index.md + expanded: false + items: + - page: docs/simpleXRPL/references/verticals/credential/issue.md + label: issue() + - page: docs/simpleXRPL/references/verticals/credential/accept.md + label: accept() + - page: docs/simpleXRPL/references/verticals/credential/delete.md + label: delete() + - page: docs/simpleXRPL/references/verticals/credential/retrieve.md + label: retrieve() + - page: docs/simpleXRPL/references/verticals/credential/list.md + label: list() + - group: Domain + page: docs/simpleXRPL/references/verticals/domain/index.md + expanded: false + items: + - page: docs/simpleXRPL/references/verticals/domain/create.md + label: create() + - page: docs/simpleXRPL/references/verticals/domain/setCredentials.md + label: setCredentials() + - page: docs/simpleXRPL/references/verticals/domain/delete.md + label: delete() + - page: docs/simpleXRPL/references/verticals/domain/retrieve.md + label: retrieve() + - page: docs/simpleXRPL/references/verticals/domain/list.md + label: list() + - group: Account + page: docs/simpleXRPL/references/verticals/account/index.md + expanded: false + items: + - page: docs/simpleXRPL/references/verticals/account/create.md + label: create() + - page: docs/simpleXRPL/references/verticals/account/activate.md + label: activate() + - page: docs/simpleXRPL/references/verticals/account/fund.md + label: fund() + - page: docs/simpleXRPL/references/verticals/account/set.md + label: set() + - page: docs/simpleXRPL/references/verticals/account/setRegularKey.md + label: setRegularKey() + - page: docs/simpleXRPL/references/verticals/account/depositPreauth.md + label: depositPreauth() + - page: docs/simpleXRPL/references/verticals/account/retrieve.md + label: retrieve() + - page: docs/simpleXRPL/references/verticals/account/listOffers.md + label: listOffers() + - page: docs/simpleXRPL/references/errors.md +- group: Amendments + expanded: false items: - page: docs/xls-85-token-escrow/index.page.tsx - page: docs/xls-81-permissioned-dexes/index.page.tsx