PHPackages                             yuanbenio/universe-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yuanbenio/universe-php-sdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yuanbenio/universe-php-sdk
==========================

Ethereum secp256k1 library in PHP

v1.0.2(5y ago)16MITPHPCI failing

Since Apr 18Pushed 5y ago4 watchersCompare

[ Source](https://github.com/yuanbenio/universe-php-sdk)[ Packagist](https://packagist.org/packages/yuanbenio/universe-php-sdk)[ RSS](/packages/yuanbenio-universe-php-sdk/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (4)Versions (5)Used By (0)

YuanBenLian SDK of PHP (v1)
===========================

[](#yuanbenlian-sdk-of-php-v1)

- YuanBenLian API Documentation

Translations
------------

[](#translations)

- [中文文档](README-cn.md)

Rely
----

[](#rely)

```
 "php-64bit": ">=7.0",
 "ext-gmp": "*",
 "ext-secp256k1": ">=0.1.0",
 "ext-keccak": "~0.2",
 "guzzlehttp/guzzle": "~6.0",
 "bitwasp/buffertools": "^0.5.0"

```

- secp256k1 :
- ext-secp256k1:
- ext-keccak:

### Attention

[](#attention)

*ECDH api is destroyed, check the commit of the latest secp256k1 before the merge of 95e99f196fd08a8b2c236ab99d7e7fec8f6dc78f*

### The dockerfile as a reference

[](#the-dockerfile-as-a-reference)

- [Dockerfile](Dockerfile)

Install
-------

[](#install)

#### from github

[](#from-github)

- git clone
- cd universe-php-sdk
- composer install

#### from composer

[](#from-composer)

- composer require yuanbenio/universe-php-sdk

YuanBenLian API return code
---------------------------

[](#yuanbenlian-api-return-code)

codedescribeokSuccess3001Invalid parameter3002Empty parameter3003Record does not exist3004Record already exists3005Permission denied: please register the public key first3006Permission denied: please contract Yuanben chain support3007Incorrect data3009Data storage fail3010Data not on YuanBen chain3011block information is empty3012Query fail3020Signature verification fail3023Parameter verification fail3021Invalid public key3022License's parameters are empty4001Error connecting to redis server4002Error connecting to the first-level node4003Broadcast transaction fail4004ABCI query fail4005Redis handling error5000Unknown errorData flow diagram
-----------------

[](#data-flow-diagram)

[![Data-flow](https://github.com/yuanbenio/universe-php-sdk/raw/master/resources/data-flow.png)](https://github.com/yuanbenio/universe-php-sdk/blob/master/resources/data-flow.png)

API Document
------------

[](#api-document)

> TestNet address:

### Metadata Introduction

[](#metadata-introduction)

nametypemustcommentsourcetypestringYeg:image,article,audio,video,custom,privateuser-definedlanguagestringY'zh-CN',default:zh-CN,user-definedtitlestringNtitleuser-definedsignaturestringYsign by secp256k1generate by systemabstractstringNContent summarydefault:content\[:200\],user-definedcategorystringNeg:"news"user-defined，if there is content, the system will add five morednastringYmetadata dnagenerate by systemparent\_dnastringN-user-defined,link an other metadatablock\_hashstringYblock\_hash on YuanBen chainuser-definedblock\_heightstringYblock\_hash corresponding block\_heightuser-definedcreatedintegerYtimestamp, eg:1506302092generate by systemcontent\_hashstringYKeccak256(content)default:Keccak256(content),user-definedextraTreeMap&lt;String, Object&gt;Nuser-defined contentuser-definedlicenseMetadata.LicenseYuser-definedlicense.typestringYthe type of licenseuser-definedlicense.parametersTreeMap&lt;String, Object&gt;Nthe parameters of licenseuser-definedsourcestringNsource link.user-defineddataTreeMap&lt;String, Object&gt;Nextension data of the typeuser-defined### Quick Start

[](#quick-start)

- Note: If you want to use the YuanBenLian OPENAPI, please contact the YuanBenLian owner to register your public key to the YuanBenLian.
- Note: the API configuration needs to be initialized before using the API method
- Note: If there is an integer used in metadata, please convert to string

### Example

[](#example)

**create private key**

```
// if you don't have private key,You can use this method to generate a private key
// generate private key
$privateKey = \YBL\Kernel\Eth\Key::createPrivateKey();
echo $privateKey . PHP_EOL;

// init key
\YBL\Kernel\Eth\Key::init($privateKey);
$private_key = \YBL\Kernel\Eth\Key::getPrivateKey()->getHex();

// if you use production env,You can contact the YuanBenLian owner to add the public key to the authorized public key.
$public_key = \YBL\Kernel\Eth\Key::getPublicKey()->getHex();
```

**Authorized secondary account**

```
$uri = "https://testnet.yuanbenlian.com";

// test key
// you can create private key
// $privateKey = \YBL\Kernel\Eth\Key::createPrivateKey();

$privateKey = '4e8c4b58b63e4584b807efa63182cff82440c263e442e21d4ac80ce857ccfbd6';

/*
 * timeout : Float describing the timeout of the request in seconds. default 30 s.
 * verify : Describes the SSL certificate verification behavior of a request.
 * Set to true to enable SSL certificate verification and use the default CA bundle provided by operating system.
 * Set to false to disable certificate verification (this is insecure!).
 * Set to a string to provide the path to a CA bundle to enable verification using a custom certificate.
 */
$config = [
    'private_key' => $privateKey,  // must
    'base_uri' => $uri,  // not must, default is https://openapi.yuanbenlian.com,
    'timeout' => 30,   // not must , default is 30
    'verify' => true,  // not must , default is true
];

$client = new \YBL\ClientBuilder($config);

$subkeys = [];

for ($i = 0; $i < 10; $i++) {
    $privateKeyTmp = \YBL\Kernel\Eth\Key::createPrivateKey();
    \YBL\Kernel\Eth\Key::init($privateKeyTmp);
    $subkeys[] = \YBL\Kernel\Eth\Key::getPublicKey()->getHex();
}

$response = $client->registerAccount($subkeys);

echo "result : " . $response->getBody()->getContents() . PHP_EOL;
```

**publish article**

```
$uri = "https://testnet.yuanbenlian.com";

// test key
// you can create private key
// $privateKey = \YBL\Kernel\Eth\Key::createPrivateKey();

$privateKey = '4e8c4b58b63e4584b807efa63182cff82440c263e442e21d4ac80ce857ccfbd6';

/*
 * timeout : Float describing the timeout of the request in seconds. default 30 s.
 * verify : Describes the SSL certificate verification behavior of a request.
 * Set to true to enable SSL certificate verification and use the default CA bundle provided by operating system.
 * Set to false to disable certificate verification (this is insecure!).
 * Set to a string to provide the path to a CA bundle to enable verification using a custom certificate.
 */
$config = [
    'private_key' => $privateKey,  // must
    'base_uri' => $uri,  // not must, default is https://openapi.yuanbenlian.com,
    'timeout' => 30,   // not must , default is 30
    'verify' => true,  // not must , default is true
];

$client = new \YBL\ClientBuilder($config);

$res = $client->searchLatestBlock();

$result = json_decode($res->getBody()->getContents(), true);

if (isset($result['code']) && $result['code'] == 'ok') {
    $latest_block_hash = $result['data']['latest_block_hash'];
    $latest_block_height = (string)$result['data']['latest_block_height'];
} else {
    echo "get latest block wrong : " . $res;
    exit;
}

$content = 'just for test!';

// build metadata parameters
// pubkey is populated by default
$data = [
    'type' => 'article',
    'language' => 'en',
    'title' => 'test ybl article',
    'category' => 'news',
    'block_hash' => $latest_block_hash,
    'block_height' => $latest_block_height,
    'created' => (string)time(),
    'content_hash' => hash('sha256', $content),  // or Keccak::hash($content,256) or other hash algorithm
    'license' => [
        'type' => 'none'
    ],
];

$metadata = $client->buildMetadata($data);

$signature = $client->sign($metadata);

echo "signature : ".$signature . PHP_EOL;

/*
 * you can use signature to generate dna
 * $client->generateDNA($signature);
 */

$metadata = $client->setSignature($metadata, $signature);

$response = $client->publishMetadata($metadata);

echo "result : " . $response->getBody()->getContents() . PHP_EOL;

/*
 * result : {"code":"ok","data":{"dna":"1AGK96C7JR6CC69JUKG0ZJLCSFODZ6GS9JNYSHKWWS3JZ7RJN5"}}
 */

$dna = '1AGK96C7JR6CC69JUKG0ZJLCSFODZ6GS9JNYSHKWWS3JZ7RJN5';

$responseMeta = $client->searchMetadata($dna);

echo "metadata info : " . $responseMeta->getBody()->getContents() . PHP_EOL;

/*
 metadata info : {"code":"ok","data":{"content_hash":"028a6011079dc3316f36198bdcc9476937ea2c3f9b705557c8e11be737b01107","created":"1555508743","block_hash":"627E5DEA02407894CA42EFE1267A9BC4F6770AB3","block_height":"323099","language":"en","signature":"af4123fb82d0ba48f99c604c3990e676f8b21266ad4c74b9632d6fd6519b16e41565453189ccfb7b390629f516eee53c40556620fcbc4b3989441f3606b11b4d00","pubkey":"02960bfff6ffd689b58c87e142e37a47ec348984dfdb79d6a069302cfac89d4368","type":"article","license":{"type":"none"},"category":"news","dna":"1AGK96C7JR6CC69JUKG0ZJLCSFODZ6GS9JNYSHKWWS3JZ7RJN5","title":"test ybl article"},"tx":{"block_hash":"32137a2f4f5d24870caeb535724cf946230f1243","block_height":323101,"sender":"1624de6420e15aee7543c19a01a12ab135416bedc6b77d86ceb373c1bb51785f192c2c8452","proposer":"","time":1555508726,"version":"v4"}}
 */
```

[more examples](https://github.com/yuanbenio/universe-php-sdk/tree/master/examples)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~130 days

Total

4

Last Release

2189d ago

Major Versions

v0.2 → v1.0.12019-04-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/3bcdb883ac5a8d3b050d97645820260d1bde745f6aa234b38849b78b3e4cdea6?d=identicon)[yuanben](/maintainers/yuanben)

---

Top Contributors

[![kooksee](https://avatars.githubusercontent.com/u/6829652?v=4)](https://github.com/kooksee "kooksee (1 commits)")

---

Tags

phpbitcoinnodecryptocurrencyECDSAeccsecp256k1bitwaspyblyuanbenlian

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yuanbenio-universe-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/yuanbenio-universe-php-sdk/health.svg)](https://phpackages.com/packages/yuanbenio-universe-php-sdk)
```

###  Alternatives

[bitwasp/secp256k1-php

PHP Extension with bindings for bitcoin/secp256k1.

58185.7k35](/packages/bitwasp-secp256k1-php)[bitwasp/bitcoin-lib

Implementation of raw transactions in bitcoin, HD wallets, Electrum wallets, and other fun stuff.

13922.3k5](/packages/bitwasp-bitcoin-lib)[kornrunner/secp256k1

Pure PHP secp256k1

37566.4k109](/packages/kornrunner-secp256k1)[fab2s/nodalflow

A PHP Nodal WorkFlow

16362.4k1](/packages/fab2s-nodalflow)[zoon/rialto

Manage Node resources from PHP

12199.4k3](/packages/zoon-rialto)[jimmerioles/bitcoin-currency-converter-php

A simple and lightweight bitcoin to currency converter and vice versa based on current exchange rates from your chosen provider: Coinbase, Coindesk, Bitpay and etc.

132.7k](/packages/jimmerioles-bitcoin-currency-converter-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
