cobo/cobo_custody

There is no license information available for the latest version (v0.2.25) of this package.

Cobo Custody php sdk

v0.2.25 2024-04-15 06:58 UTC

README

License: GPL v2 GitHub Release

About

This repository contains the official PHP SDK for Cobo WaaS API, enabling developers to integrate with Cobo's Custodial and/or MPC services seamlessly using the PHP programming language.

Documentation

To access the API documentation, navigate to the API references.

For more information on Cobo's PHP SDK, refer to the PHP SDK Guide.

Usage

Before You Begin

Ensure that you have created an account and configured Cobo's Custodial and/or MPC services. For detailed instructions, please refer to the Quickstart guide.

Requirements

PHP 7.0 or newer.

Installation

The cobo_custody library can be conveniently installed using Composer.

  • first you need to install Composer

  • then add dependency in composer.json

{
  "require": {
    "cobo/cobo_custody": "0.2.25"
  }
}

Code Sample

Generate Key Pair

<?php
require 'vendor/autoload.php';

use Cobo\Custody\Config;
use Cobo\Custody\LocalSigner;
use Cobo\Custody\Client;
$key = LocalSigner::generateKeyPair();
echo "apiSecret:", $key['apiSecret'],"\n";
echo "apiKey:", $key['apiKey'];

Initialize RestClient

<?php
require 'vendor/autoload.php';

use Cobo\Custody\Config;
use Cobo\Custody\LocalSigner;
use Cobo\Custody\Client;

$client = new Client($signer, Config::DEV, false);

Initialize ApiSigner

ApiSigner can be instantiated through $signer = new LocalSigner($key['apiSecret']);

$signer = new LocalSigner($key['apiSecret']);

In certain scenarios, the private key may be restricted from export, such as when it is stored in AWS Key Management Service (KMS). In such cases, please pass in a custom implementation using the ApiSigner interface:

Complete Code Sample

<?php
require 'vendor/autoload.php';

use Cobo\Custody\Config;
use Cobo\Custody\LocalSigner;
use Cobo\Custody\Client;

$key = LocalSigner::generateKeyPair();
echo "apiSecret:", $key['apiSecret'],"\n";
echo "apiKey:", $key['apiKey'];

$signer = new LocalSigner($key['apiSecret']);
$client = new Client($signer, Config::DEV, false);
$res = $client->getAccountInfo();

?>