PHPackages                             linland/php-eos-rpc-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. linland/php-eos-rpc-sdk

ActiveLibrary

linland/php-eos-rpc-sdk
=======================

PHP SDK for the EOS RPC API

043PHP

Since Nov 25Pushed 6y agoCompare

[ Source](https://github.com/linland/php-eos-rpc-sdk)[ Packagist](https://packagist.org/packages/linland/php-eos-rpc-sdk)[ RSS](/packages/linland-php-eos-rpc-sdk/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

The PHP SDK for the EOS RPC API
===============================

[](#the-php-sdk-for-the-eos-rpc-api)

A PHP wrapper for the EOS Chain/Wallet RPC API.

Background
----------

[](#background)

You can check out the [RPC API reference](https://developers.eos.io/eosio-nodeos/reference) but beware that some of the newer methods are missing. Wallet RPC APIs are implemented as [v1.1.0 of RPC API reference](https://developers.eos.io/eosio-nodeos/v1.1.0/reference). Also, some of the examples in those docs use outdated syntax.

Installing
----------

[](#installing)

```
composer require manamine/php-eos-rpc-sdk
```

Configuration
-------------

[](#configuration)

Create a dotenv `.env` file in the project root, with your favorite RPC API host and KEOSD. You can use `.env.example` as a template:

```
cp .env.example .env

```

Usage
-----

[](#usage)

There is a shiny factory method to auto instantiate all dependencies:

```
$api = (new ChainFactory)->api();
$walapi = (new WalletFactory)->api();
$eos = (new EosRpc($api, $walapi));
```

Examples
--------

[](#examples)

To get you started, there is a simple example runner which covers all API commands.

Just run this via cli to see example output for all commands:

```
cd examples
php chain.php
php wallet.php
php eosrpc.php

```

API Methods
-----------

[](#api-methods)

Almost Chain/Wallet API methods are covered.

Chain APIs
----------

[](#chain-apis)

### Get Info

[](#get-info)

Get latest information related to a node

```
echo $api->getInfo();
```

### Get Block

[](#get-block)

Get information related to a block

```
echo $api->getBlock("1337");
```

### Get Block Header State

[](#get-block-header-state)

Get information related to a block header state

```
echo $api->getBlockHeaderState("0016e48707b181d93117b07451d9837526eba34a9a37125689fb5a73a5d28a38");
```

### Get Account

[](#get-account)

Get information related to an account

```
$api->getAccount("blockmatrix1");
```

### Get Code

[](#get-code)

Fetch smart contract code

```
echo $api->getCode("eosio.token");
```

### Get Table Rows

[](#get-table-rows)

Fetch smart contract data from an account

```
echo $api->getTableRows("eosio", "eosio", "producers", ["limit" => 10]);
```

### Get Currency Balance

[](#get-currency-balance)

Fetch currency balance(s) for an account

```
echo $api->getCurrencyBalance("eosio.token", "eosdacserver");
```

### Get Currency Stats

[](#get-currency-stats)

Fetch stats for a currency

```
echo $api->getCurrencyStats("eosio.token", "EOS");
```

### Get ABI

[](#get-abi)

Get an account ABI

```
echo $api->getAbi("eosio.token");
```

### Get Raw Code and ABI

[](#get-raw-code-and-abi)

Get raw code and ABI

```
echo $api->getRawCodeAndAbi("eosio.token");
```

### Get Producers

[](#get-producers)

List the producers

```
echo $api->getProducers(10);
```

### ABI JSON To Bin

[](#abi-json-to-bin)

Serialize json to binary hex

```
echo $api->abiJsonToBin("eosio.token", "transfer", ["blockmatrix1", "blockmatrix1", "7.0000 EOS", "Testy McTest"]);
```

### ABI Bin To JSON

[](#abi-bin-to-json)

Serialize back binary hex to json

```
echo $api->abiBinToJson("eosio.token", "transfer", "10babbd94888683c10babbd94888683c701101000000000004454f53000000000c5465737479204d6354657374");
```

### Get Required Keys

[](#get-required-keys)

Get the required keys needed to sign a transaction

```
echo $api->getRequiredKeys(
     [
         "expiration" => "2018-08-23T05.00.00",
         "ref_block_num" => 15078,
         "ref_block_prefix" => 1071971392,
         "max_net_usage_words" => 0,
         "delay_sec" => 0,
         "context_free_actions" => [],
         "actions" => [
             [
                 "account" => "eosio.token",
                 "name" => "transfer",
                 "authorization" => [
                     [
                         "actor" => "user",
                         "permission" => "active"
                     ]
                 ],
                 "data" => "00000000007015d6000000005c95b1ca102700000000000004454f53000000000c757365722d3e746573746572"
             ]
         ],
         "transaction_extensions" => []
     ],
     [
         "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4"
     ]
 );
```

### Push Transaction

[](#push-transaction)

Push a transaction

```
echo $api->pushTransaction("2018-08-23T05:29:39", "15780", "90170226",
    [
        "actions" => [
            [
                "account" => "eosio.token",
                "name" => "transfer",
                "authorization" => [
                    [
                        "actor" => "user",
                        "permission" => "active"
                    ]
                ],
                "data" => "00000000007015d6000000005c95b1ca102700000000000004454f53000000000c757365722d3e746573746572"
            ]
        ],
        "signatures" => [
            "SIG_K1_KaGHyi59BRqfaDUK6424TYEWcUhWxAG7BLCgYC8vwYNgaHgGLpduTUbNQEsfL8xLzboK8W9T2X69bNpqozTQVCbRSNJWFd"
        ]
    ]
);
```

### Push Transactions

[](#push-transactions)

Push transactions

```
echo $api->pushTransactions(
    [
        [
            "compression" => "none",
            "transaction" => [
                "expiration" => "2018-08-23T06:27:26",
                "ref_block_num" => 22017,
                "ref_block_prefix" => 3920123292,
                "context_free_actions" => [],
                "actions" => [
                    [
                        "account" => "eosio.token",
                        "name" => "transfer",
                        "authorization" => [
                            [
                                "actor" => "user",
                                "permission" => "active"
                            ]
                        ],
                        "data" => "00000000007015d6000000005c95b1ca102700000000000004454f53000000000c757365722d3e746573746572"
                    ]
                ],
                "transaction_extensions" => []
            ],
            "signatures" => [
                "SIG_K1_JzN9DnpyhKfjoef3C2TZBTPA5b6ftwuEBnBpvzkueVXThJ34PFFpUFgqyayfXjeLRc15JmZmDiMYAFX99hUgX8vkGAYcnx"
            ]
        ],
        [
            "compression" => "none",
            "transaction" => [
                "expiration" => "2018-08-23T06:27:26",
                "ref_block_num" => 22017,
                "ref_block_prefix" => 3920123292,
                "context_free_actions" => [],
                "actions" => [
                    [
                        "account" => "eosio.token",
                        "name" => "transfer",
                        "authorization" => [
                            [
                                "actor" => "tester",
                                "permission" => "active"
                            ]
                        ],
                        "data" => "000000005c95b1ca00000000007015d6881300000000000004454f53000000000c7465737465722d3e75736572"
                    ]
                ],
                "transaction_extensions" => []
            ],
            "signatures" => [
                "SIG_K1_KZ2M4AG59tptdRCpqbwzMQvBv1dce5btJCJiCVVy96fTGepApGXqJAwsi17g8AQdJjUQB4R62PprfdUdRYHGdBqK1z9Sx9"
            ]
        ]
    ]
);
```

Wallet APIs
-----------

[](#wallet-apis)

### Create

[](#create)

Creates a new wallet with the given name

```
echo $walapi->create("testwallet");
```

### Open

[](#open)

Opens an existing wallet of the given name

```
echo $walapi->open("testwallet");
```

### Lock

[](#lock)

Locks an existing wallet of the given name

```
echo $walapi->lock("testwallet");
```

### Lock All

[](#lock-all)

Locks all existing wallets

```
echo $walapi->lockAll();
```

### Unlock

[](#unlock)

Unlocks a wallet with the given name and password

```
echo $walapi->unlock(["testwallet", "PW5Jb8RAZP6CBjjMLPser3T8i8k9hZXZkMBJ8kb1p6f6hAg2n68jY"]);
```

### Import Key

[](#import-key)

Imports a private key to the wallet of the given name

```
echo $walapi->importKey(["testwallet", "5Jmsawgsp1tQ3GD6JyGCwy1dcvqKZgX6ugMVMdjirx85iv5VyPR"]);
```

### Remove Key

[](#remove-key)

Removes a key pair from the wallet of the given name

```
echo $walapi->removeKey(["testwallet", "PW5Jb8RAZP6CBjjMLPser3T8i8k9hZXZkMBJ8kb1p6f6hAg2n68jY", "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4"]);
```

### Create Key

[](#create-key)

Creates a key pair and import

```
echo $walapi->createKey(["testwallet", "K1"]);
```

### List Wallets

[](#list-wallets)

Lists all wallets

```
echo $walapi->listWallets();
```

### List Keys

[](#list-keys)

Lists all key pairs from the wallet of the given name and password

```
echo $walapi->listKeys(["testwallet", "PW5Jb8RAZP6CBjjMLPser3T8i8k9hZXZkMBJ8kb1p6f6hAg2n68jY"]);
```

### Get Public Keys

[](#get-public-keys)

Lists all public keys across all wallets

```
echo $walapi->getPublicKeys();
```

### Set Timeout

[](#set-timeout)

Sets wallet auto lock timeout (in seconds)

```
echo $walapi->setTimeout(60);
```

### Sign Transaction

[](#sign-transaction)

Signs a transaction

```
echo $walapi->signTransaction(
    [
        "expiration" => "2018-08-23T06:35:30",
        "ref_block_num" => 22985,
        "ref_block_prefix" => 3016594541,
        "max_net_usage_workds" => 0,
        "delay_sec" => 0,
        "context_free_actions" => [],
        "actions" => [
            [
                "account" => "eosio.token",
                "name" => "transfer",
                "authorization" => [
                    [
                        "actor" => "user",
                        "permission" => "active"
                    ]
                ],
                "data" => "00000000007015d6000000005c95b1ca102700000000000004454f53000000000c757365722d3e746573746572"
            ]
        ],
        "transaction_extensions" => []
    ],
    [
        "EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4"
    ],
    "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"
);
```

EOS Wrapper APIs
----------------

[](#eos-wrapper-apis)

### Prerequisites

[](#prerequisites)

Need to set wallet name and password

```
$eos->setWalletInfo("testwallet", "PW5Jb8RAZP6CBjjMLPser3T8i8k9hZXZkMBJ8kb1p6f6hAg2n68jY");
```

### Push Transaction

[](#push-transaction-1)

Push a transaction

```
echo $eos->pushTransaction(
    [
        [
            "account" => "eosio.token",
            "name" => "transfer",
            "authorization" => [
                [
                    "actor" => "user",
                    "permission" => "active"
                ]
            ],
            "data" => [
                "from" => "user",
                "to" => "tester",
                "quantity" => "1.0000 EOS",
                "memo" => "memo"
            ]
        ]
    ]
);
```

### Make Transaction

[](#make-transaction)

Make a transaction (useful for pushTransactions)

```
$trx = $eos->makeTransaction(
    [
        [
            "account" => "eosio.token",
            "name" => "transfer",
            "authorization" => [
                [
                    "actor" => "user",
                    "permission" => "active"
                ]
            ],
            "data" => [
                "from" => "user",
                "to" => "tester",
                "quantity" => "1.0000 EOS",
                "memo" => "memo"
            ]
        ]
    ]
);
```

### Push Transactions

[](#push-transactions-1)

Push transactions

```
$trx_ids = $eos->pushTransactions(
    [
        $eos->makeTransaction(
            [
                [
                    "account" => "eosio.token",
                    "name" => "transfer",
                    "authorization" => [
                        [
                            "actor" => "user",
                            "permission" => "active"
                        ]
                    ],
                    "data" => [
                        "from" => "user",
                        "to" => "tester",
                        "quantity" => "1.0000 EOS",
                        "memo" => "memo"
                    ]
                ]
            ]
        ),
        $eos->makeTransaction(
            [
                [
                    "account" => "eosio.token",
                    "name" => "transfer",
                    "authorization" => [
                        [
                            "actor" => "tester",
                            "permission" => "active"
                        ]
                    ],
                    "data" => [
                        "from" => "tester",
                        "to" => "user",
                        "quantity" => "0.5000 EOS",
                        "memo" => "memo"
                    ]
                ]
            ]
        )
    ]
);
foreach ($trx_ids as $key => $value) {
    echo $trx_ids[$key]['transaction_id'] . PHP_EOL;
}
```

### Push Action

[](#push-action)

Push an action

```
echo $eos->pushAction("eosio", "buyram", ["payer"=>"tester","receiver"=>"tester","quant"=>"1.0000 EOS"], ["actor"=>"tester","permission"=>"active"]);
```

### Transfer

[](#transfer)

Transfers token

```
echo $eos->transfer("user", "tester", "1.0000 EOS", "memo");
```

### Create Key Pair

[](#create-key-pair)

Creates a key pair and returns

```
$keyPair = $eos->createKeyPair("K1");
echo "$keyPair[0], $keyPair[1]";
```

Tests
-----

[](#tests)

To run the test suites, simply execute:

```
vendor/bin/phpunit
```

If you wanna get fancy and check code coverage:

```
vendor/bin/phpunit --coverage-html tests/coverage
```

If you're really bored, you might wanna run some static analysis:

```
vendor/bin/phpmetrics --report-html="tests/static" .
```

Contributing
------------

[](#contributing)

All contributions are welcome! Just fire up a PR, make sure your code style is PSR-2 compliant:

```
vendor/bin/php-cs-fixer fix --verbose
```

License
-------

[](#license)

Free for everyone!

MIT License

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 51.1% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d37dfd58de04755bca5cb108c281fefc3346ceb5e44c89c85c61908780ffd265?d=identicon)[linland](/maintainers/linland)

---

Top Contributors

[![alienzin](https://avatars.githubusercontent.com/u/40164204?v=4)](https://github.com/alienzin "alienzin (24 commits)")[![pete001](https://avatars.githubusercontent.com/u/410428?v=4)](https://github.com/pete001 "pete001 (15 commits)")[![linland](https://avatars.githubusercontent.com/u/12590892?v=4)](https://github.com/linland "linland (6 commits)")[![Crypto2](https://avatars.githubusercontent.com/u/7625236?v=4)](https://github.com/Crypto2 "Crypto2 (1 commits)")[![skirmantasjanuskas](https://avatars.githubusercontent.com/u/25622287?v=4)](https://github.com/skirmantasjanuskas "skirmantasjanuskas (1 commits)")

### Embed Badge

![Health badge](/badges/linland-php-eos-rpc-sdk/health.svg)

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

PHPackages © 2026

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