For the complete documentation index, see llms.txt. This page is also available as Markdown.

XRP Provider API

TokenPocket Extension injects an XRP Provider into the page. Developers can use it to connect the current address and initiate XRP transfers.

Provider Injection

The following object is available on the page:

window.tokenpocket.xrp

The current XRP interface is lightweight and mainly focused on address connection and native XRP transfers.

Quick Start

Get Current Address

const wallet = await window.tokenpocket.xrp.connect();
console.log(wallet.address);

Send XRP

const res = await window.tokenpocket.xrp.sendXrp({
  from: 'r...',
  to: 'r...',
  amount: '1',
  destinationTag: '10001',
});

console.log(res.txid);

API List

connect

Requests connection for the current site and returns the active XRP address.

Notes:

  • Returns the currently selected XRP address.

  • Throws an error if the user rejects authorization.

Example:

sendXrp

Sends a native XRP transfer.

Parameters:

  • from: Sender address

  • to: Receiver address

  • amount: Transfer amount

  • destinationTag: Optional destination tag

Returns:

  • txid: Transaction hash

Example:

sendToken

Token transfers are not supported in the current version.

Notes:

  • The current implementation always returns Not supported!.

Error Handling

Use try/catch for all Provider calls.

Common failure cases:

  • User rejects the connection request.

  • User rejects transfer confirmation.

  • Invalid parameter format.

  • No XRP address is available in the current wallet.

Compatibility Notes

  • Only window.tokenpocket.xrp is injected.

  • The current version mainly supports address connection and sendXrp.

  • sendToken is not available yet.