定制 xrpl/xumm-sdk-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xrpl/xumm-sdk-php

最新稳定版本:v1.2.0

Composer 安装命令:

composer require xrpl/xumm-sdk-php

包简介

A PHP SDK for Xumm by XRPLabs.

README 文档

README

main workflow

Xumm SDK (PHP)

Requirements

Installation

To install, run:

composer require xrpl/xumm-sdk-php

Usage

First obtain Xumm API credentials by registering your app.

Initialize the Xumm SDK in your application:

// Either pass API credentials through the constructor 
$sdk = new XummSdk($apiKey, $apiSecret);

// Or set them as environment variables. See .env.example for the expected variable names.
// Note: the .env file is mostly applicable when contributing to the SDK itself.  
$sdk = XummSdk();

Each call on the SDK object will return a corresponding value object implementing the XummResponse interface.

Create a payload

To create a payload, pass an instance of Xrpl\XummSdkPhp\Payload to XummSdk::createPayload(). This instance should hold an associative array transactionBody, and can hold some options and custom metadata. For more elaborate documentation on how to construct a payload, please refer to the API docs.

A simple example could look like this:

$sdk->createPayload(
    new Payload(
        transactionBody: [
            'TransactionType' => 'Payment',
            'Destination' => 'rPdvC6ccq8hCdPKSPJkPmyZ4Mi1oG2FFkT',
            'Fee' => '12'
        ],
        customMeta: new CustomMeta(identifier: 'my-custom-identifier'),
    )
);

This will return an instance of Xrpl\XummSdkPhp\Response\CreatePayload\CreatedPayload.

Subscribe to a payload

After you create a payload, you can pass the returned CreatedPayload to XummSdk::subscribe() to subscribe to live payload status changes. This returns an instance of Xrpl\XummSdkPhp\Subscriber\Subscription.

Changes to a payload status include:

  • The payload was by a XUMM App user (web page)
  • The payload was by a XUMM App user (in the app)
  • Payload expiration updates (remaining time in seconds)
  • The payload was resolved by rejecting
  • The payload was resolved by accepting (signing)

Status updates can be handled by passing a callback function as a second argument to XummSdk::subscribe. The subscription ends by either:

  • returning non-void from the callback function, or
  • explicitly calling Subscription::end().

Other methods

The SDK also supports the XUMM API's helper methods, such as ping, getCuratedAssets, and getRates. Again, these will all return corresponding implementations of XummResponse.

Contributing

For contributing to development of this package, refer to CONTRIBUTING.md.

统计信息

  • 总下载量: 1.9k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 7
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-09