PHPackages                             cityofzion/neo-php - 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. cityofzion/neo-php

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

cityofzion/neo-php
==================

NEO blockchain implementation for PHP

1.0.0(7y ago)152.0k↓33.3%14[10 issues](https://github.com/CityOfZion/neo-php/issues)MITPHP

Since Dec 3Pushed 5y ago7 watchersCompare

[ Source](https://github.com/CityOfZion/neo-php)[ Packagist](https://packagist.org/packages/cityofzion/neo-php)[ RSS](/packages/cityofzion-neo-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

 [![](https://camo.githubusercontent.com/063197773e2300b207cfe5d943f2eec5ad9e1c902a99b87ade0e70ab7cdff1e8/687474703a2f2f7265732e636c6f7564696e6172792e636f6d2f76696473792f696d6167652f75706c6f61642f76313530333136303832302f436f5a5f49636f6e5f4441524b424c55455f3230307831373870785f6f713067786d2e706e67)](https://camo.githubusercontent.com/063197773e2300b207cfe5d943f2eec5ad9e1c902a99b87ade0e70ab7cdff1e8/687474703a2f2f7265732e636c6f7564696e6172792e636f6d2f76696473792f696d6167652f75706c6f61642f76313530333136303832302f436f5a5f49636f6e5f4441524b424c55455f3230307831373870785f6f713067786d2e706e67)

neo-php
=======

[](#neo-php)

 PHP SDK for the NEO blockchain.

Overview
--------

[](#overview)

### What does it currently do

[](#what-does-it-currently-do)

- Installation though Composer
- Open, create and encrypt unencrypted wallets
- Create and open encrypted wallet
- Minimal NEP-5 interation (token balance requesting and Smart Contract parameter factory)
- All RPC functions are integrated.
- Address validation
- It contains a cold wallet generator
- Coinmarketcap API integration

### What will (should) it do

[](#what-will-should-it-do)

- Do wallet transactions for: NEO, GAS and NEP-5 Tokens
- Build, deploy, and run smart contracts
- A lot more

### Documentation

[](#documentation)

Currently there isn't much documentation besides this Readme. We could use it! Do a PR if you'd like to help us :). [Though there are a lot of examples](examples/)

### Get help or give help

[](#get-help-or-give-help)

- Open a new [issue](https://github.com/CityOfZion/neo-php/issues/new) if you encounter a problem.
- Or ping **@Deanpress** or **@Woodehh** on the [NEO Discord](https://discord.gg/R8v48YA).
- Pull requests welcome. You can help with wallet functionality, writing tests or documentation, or on any other feature you deem awesome.

Getting started
---------------

[](#getting-started)

To start using neo-php you need to have [composer](https://getcomposer.org/) installed. When you're ready openup a terminal and type in:

```
composer require cityofzion/neo-php @dev

```

From there on include the autoloader and you can use all of the juicy neo-php features.

### Wallet functionality:

[](#wallet-functionality)

The wallet part of neo-php consists out of initializers that have multiple functions.

**Create new unencrypted wallet**

```
$newWallet = new NeoPHP\NeoWallet();
```

**Open an unencrypted wallet**

```
$wallet = new NeoPHP\NeoWallet("KzfUdP9MbsuL4Ejo1rTWve4JZfa7m1hc397JGXTHhNqJDAqMxZYu");
```

**Create new encrypted wallet**

```
$wallet = new NeoPHP\NeoWallet();
$wallet->encryptWallet("passphrase");
```

**Open an encrypted wallet**

```
$wallet = new NeoPHP\NeoWallet("6PYMFa9gMAcBrTaAs8JyDrtoGLqb45P8dnmUfVVNcfLd9xKUdffSNfKWKp","passphrase");
```

**Encrypt an existing wallet**

```
$wallet = new NeoPHP\NeoWallet("KzfUdP9MbsuL4Ejo1rTWve4JZfa7m1hc397JGXTHhNqJDAqMxZYu");
$wallet->encryptWallet("passphrase");
```

**BOOL to test if wallet is an encrypted wallet**

```
$wallet->isNEP2();
```

**String get the encrypted address, when isNEP2()**

```
$wallet->getEncryptedKey();
```

**String get wif for initialized wallet**

```
$wallet->getWif();
```

**String get address for initialized wallet**

```
$wallet->getAddress();
```

**String get key for initialized wallet**

```
$wallet->getPrivateKey()
```

### Minimal NEP-5 integration

[](#minimal-nep-5-integration)

We're working on NEP5 integration. For now we're able to request the majority of the NEP5 tokens balance with a specified address.

**Requesting NEP-5 Token balance for address**

```
$rpcObject = new NeoRPC();
$rpcObject->setNode("https://seed1.redpulse.com:10331");
\NeoPHP\NEP5::getTokenBalance($rpcObject,NeoPHP\NeoAssets::ASSET_ZPT,"AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ1X");
\NeoPHP\NEP5::getTokenBalance($rpcObject,NeoPHP\NeoAssets::ASSET_TKY,"AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ1X")
```

**Right now we have the following "assets" which you can request the balance for:**

  Token Asset constant   Ontology NeoPHP\\NeoAssets::ASSET\_ONT   THEKEY NeoPHP\\NeoAssets::ASSET\_TKY   Congierce token NeoPHP\\NeoAssets::ASSET\_CGE   Alphacat NeoPHP\\NeoAssets::ASSET\_ACAT   Narrative Token NeoPHP\\NeoAssets::ASSET\_NRVE   Red Pulse NeoPHP\\NeoAssets::ASSET\_RPX   DeepBrainChain NeoPHP\\NeoAssets::ASSET\_DBC   QLink NeoPHP\\NeoAssets::ASSET\_QLC   Trinity Network Credit NeoPHP\\NeoAssets::ASSET\_TN   Zeepin Token NeoPHP\\NeoAssets::ASSET\_ZPT   PikcioChain NeoPHP\\NeoAssets::ASSET\_PKC ### The RPC

[](#the-rpc)

The RPC is the way to talk to the different blockchain nodes. For example: We use it to request the balance for the NEP-5 tokens.

**Connecting to a RPC Node**

```
$neo = new NeoRPC(); #use false as argument to go to testnet
//$neo->setNode($neo->getFastestNode());
$neo->setNode("http://seed5.neo.org:10332");
```

**Asking for balance using the CityOfZion API**

```
$neo->getBalance($testAddress);
```

**Query the account asset information, according to the account address.**

```
$neo->getAccountState($testAddress);
```

**Query the asset information, based on the specified asset number.**

```
$neo->getAssetState($neoAssetID);
```

**Returns the hash of the tallest block in the main chain.**

```
$neo->getBestBlockHash();
```

**Returns the corresponding block information according to the specified index OR hash.**

```
$neo->getBlock("0x56adb8cc0de3e4fff7b8641988c83bfca214802d263495403055efdd437234c4");
$neo->getBlock(1533325);
```

**Gets the number of blocks in the main chain.**

```
$neo->getBlockCount();
```

**Calculate claim transaction amounts in order use sendrawtransaction to make a claim.**

```
$neo->getBlockSysFee($neo->getBlockCount()-1);
```

**Returns the hash value of the corresponding block, based on the specified index.**

```
$neo->getBlockHash($neo->getBlockCount()-1);
```

**Gets the current number of connections for the node.**

```
$neo->getConnectionCount();
```

**Query contract information, according to the contract script hash.**

```
$neo->getContractState("602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7");
```

**Obtain the list of unconfirmed transactions in memory.**

```
$neo->getRawMemPool();
```

**Returns the corresponding transaction information, based on the specified hash value.**

```
$neo->getRawTransaction("602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7",true);
```

**Query contract information, according to the contract script hash.**

```
$neo->getStorage("c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b", "74657374");
```

**Returns the corresponding transaction output information (returned change), based on the specified hash and index.**

```
$neo->getTxOut("0e3c0f477d80acda1c45650b3260e2410287ef78c291f6e02f0214daca2bd2cf",0);
```

**Broadcasts a transaction over the NEO network. There are many kinds of transactions, as specified in the network protocol [documentation](http://docs.neo.org/en-us/node/network-protocol.html)**

```
$transaction_id = ""; //A hexadecimal string that has been serialized, after the signed transaction in the program.
$broadcastTransaction = $neo->sendRawTransaction($transaction_id);
if ($broadcastTransaction)
	echo "Sent";
else
	echo "Hasn't been sent";
```

**Validate an address**

```
if ($neo->validateAddress("AXCLjFvfi47R1sKLrebbRJnqWgbcsncfro"))
	echo "Address is valid";
else
	echo "Address is not valid";
```

### NEO Cold wallet generator

[](#neo-cold-wallet-generator)

You can also run the [cli-create-wallet-interactive.php](examples/cli-create-wallet-interactive.php) example to generate a new wallet. You can do so on a fresh virtual and disconnected Linux distro, you can do a clean run and keep your wallet safe.

### CoinMarketCap integration

[](#coinmarketcap-integration)

Neo-PHP Features a full CoinMarketCap API integration.

**To initiate the object**

```
//setup coinmarketcap object
$cmcObject = new \NeoPHP\CoinMarketCap();

//set currency, if not set it defaults to USD
$cmcObject->setCurrency("EUR");
```

**To request the ticker**

```
print_r($cmcObject->getTicker());
```

Arguments are start and limit. Similar to MySQL start and limit

**To request the ticker for a specific currency**

```
//get ticket for asset GAS
print_r($cmcObject->getTickerForAsset(\NeoPHP\Assets\NeoAssets::ASSET_GAS));
//get ticket for asset NEO
print_r($cmcObject->getTickerForAsset(\NeoPHP\Assets\NeoAssets::ASSET_NEO));
```

[Check NEP-5 asset constants of this documentation for the right assets](#minimal-nep-5-integration)

**To get global data**

```
//get global data
print_r($cmcObject->getGlobalData());
```

[Check NEP-5 asset constants of this documentation for the right assets](#minimal-nep-5-integration)

Created by
==========

[](#created-by)

- **Benjamin de Bos** ([LinkedIn](https://www.linkedin.com/in/benjamindebos/)) - [Neodius (NEO Blockchain App)](https://github.com/Cityofzion/Neodius) &amp; [ITSVision](https://github.com/ITSVision)
- **Dean van Dugteren** ([LinkedIn](https://www.linkedin.com/in/deanpress/)) - [NEO dApp Starter Kit](https://github.com/deanpress/neo-dapp-starter-kit), [Vidiato](https://vidiato.com), [Click.DJ](https://click.dj)

Check out [Neodius](https://github.com/ITSVision/Nodius)

Licensed under [MIT License](License)

Enjoy!

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

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

Unknown

Total

1

Last Release

2714d ago

### Community

Maintainers

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

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

---

Top Contributors

[![Woodehh](https://avatars.githubusercontent.com/u/6039482?v=4)](https://github.com/Woodehh "Woodehh (109 commits)")[![deanpress](https://avatars.githubusercontent.com/u/31391056?v=4)](https://github.com/deanpress "deanpress (23 commits)")[![pepijnolivier](https://avatars.githubusercontent.com/u/2015108?v=4)](https://github.com/pepijnolivier "pepijnolivier (19 commits)")[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (2 commits)")

### Embed Badge

![Health badge](/badges/cityofzion-neo-php/health.svg)

```
[![Health](https://phpackages.com/badges/cityofzion-neo-php/health.svg)](https://phpackages.com/packages/cityofzion-neo-php)
```

###  Alternatives

[daverandom/exceptional-json

JSON encoding and decoding that throws exceptions on failure

321.4M9](/packages/daverandom-exceptional-json)

PHPackages © 2026

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