{"id":13756730,"url":"https://github.com/CityOfZion/neo-php","last_synced_at":"2025-05-10T04:30:53.797Z","repository":{"id":56953078,"uuid":"112029057","full_name":"CityOfZion/neo-php","owner":"CityOfZion","description":"A php wrapper for the neo blockchain","archived":false,"fork":false,"pushed_at":"2021-01-13T10:02:09.000Z","size":151,"stargazers_count":14,"open_issues_count":10,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-05T07:51:23.057Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CityOfZion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-25T19:28:58.000Z","updated_at":"2024-01-19T10:18:34.000Z","dependencies_parsed_at":"2022-08-21T08:20:32.019Z","dependency_job_id":null,"html_url":"https://github.com/CityOfZion/neo-php","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CityOfZion%2Fneo-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CityOfZion%2Fneo-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CityOfZion%2Fneo-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CityOfZion%2Fneo-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CityOfZion","download_url":"https://codeload.github.com/CityOfZion/neo-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253365179,"owners_count":21897180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T11:00:52.281Z","updated_at":"2025-05-10T04:30:53.535Z","avatar_url":"https://github.com/CityOfZion.png","language":"PHP","funding_links":[],"categories":["SDKs"],"sub_categories":["MainNet and TestNet (2.7.6+)"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg\n    src=\"http://res.cloudinary.com/vidsy/image/upload/v1503160820/CoZ_Icon_DARKBLUE_200x178px_oq0gxm.png\"\n    width=\"125px;\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eneo-php\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n\tPHP SDK for the NEO blockchain. \n\u003c/p\u003e\n\n\n## Overview\n\n### What does it currently do\n- Installation though Composer\n- Open, create and encrypt unencrypted wallets\n- Create and open encrypted wallet\n- Minimal NEP-5 interation (token balance requesting and Smart Contract parameter factory)\n- All RPC functions are integrated. \n- Address validation\n- It contains a cold wallet generator\n- Coinmarketcap API integration\n\n### What will (should) it do\n- Do wallet transactions for: NEO, GAS and NEP-5 Tokens\n- Build, deploy, and run smart contracts\n- A lot more\n\n### Documentation\nCurrently 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/)\n\n### Get help or give help\n\n- Open a new [issue](https://github.com/CityOfZion/neo-php/issues/new) if you encounter a problem.\n- Or ping **@Deanpress**  or **@Woodehh** on the [NEO Discord](https://discord.gg/R8v48YA).\n- Pull requests welcome. You can help with wallet functionality, writing tests\n  or documentation, or on any other feature you deem awesome.\n\n## Getting started\nTo start using neo-php you need to have [composer](https://getcomposer.org/) installed. When you're ready openup a terminal and type in:\n```\ncomposer require cityofzion/neo-php @dev\n```\nFrom there on include the autoloader and you can use all of the juicy neo-php features.\n\n### Wallet functionality:\nThe wallet part of neo-php consists out of initializers that have multiple functions.\n\n**Create new unencrypted wallet**\n```php\n$newWallet = new NeoPHP\\NeoWallet();\n```\n\n**Open an unencrypted wallet**\n```php\n$wallet = new NeoPHP\\NeoWallet(\"KzfUdP9MbsuL4Ejo1rTWve4JZfa7m1hc397JGXTHhNqJDAqMxZYu\");\n```\n\n**Create new encrypted wallet**\n```php\n$wallet = new NeoPHP\\NeoWallet();\n$wallet-\u003eencryptWallet(\"passphrase\");\n```\n\n**Open an encrypted wallet**\n```php\n$wallet = new NeoPHP\\NeoWallet(\"6PYMFa9gMAcBrTaAs8JyDrtoGLqb45P8dnmUfVVNcfLd9xKUdffSNfKWKp\",\"passphrase\");\n```\n\n**Encrypt an existing wallet**\n```php\n$wallet = new NeoPHP\\NeoWallet(\"KzfUdP9MbsuL4Ejo1rTWve4JZfa7m1hc397JGXTHhNqJDAqMxZYu\");\n$wallet-\u003eencryptWallet(\"passphrase\");\n```\n\n**BOOL to test if wallet is an encrypted wallet**\n```php\n$wallet-\u003eisNEP2();\n```\n\n**String get the encrypted address, when isNEP2()**\n```php\n$wallet-\u003egetEncryptedKey();\n```\n\n**String get wif for initialized wallet**\n```php\n$wallet-\u003egetWif();\n```\n\n**String get address for initialized wallet**\n```php\n$wallet-\u003egetAddress();\n```\n\n**String get key for initialized wallet**\n```php\n$wallet-\u003egetPrivateKey()\n```\n\n### Minimal NEP-5 integration\nWe're working on NEP5 integration. For now we're able to request the majority of the NEP5 tokens balance with a specified address.\n\n**Requesting NEP-5 Token balance for address**\n```php\n$rpcObject = new NeoRPC();\n$rpcObject-\u003esetNode(\"https://seed1.redpulse.com:10331\");\n\\NeoPHP\\NEP5::getTokenBalance($rpcObject,NeoPHP\\NeoAssets::ASSET_ZPT,\"AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ1X\");\n\\NeoPHP\\NEP5::getTokenBalance($rpcObject,NeoPHP\\NeoAssets::ASSET_TKY,\"AKDVzYGLczmykdtRaejgvWeZrvdkVEvQ1X\")\n```\n\n**Right now we have the following \"assets\" which you can request the balance for:**\n\n\u003ctable\u003e\n\t\u003ctr\u003e\n\t\t\u003cth\u003eToken\u003c/th\u003e\n\t\t\u003cth\u003eAsset constant\u003c/th\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eOntology\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_ONT\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eTHEKEY\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_TKY\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eCongierce token\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_CGE\u003c/td\u003e\n\t\u003c/tr\u003e\t\t\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eAlphacat\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_ACAT\u003c/td\u003e\n\t\u003c/tr\u003e\t\t\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eNarrative Token\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_NRVE\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eRed Pulse\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_RPX\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eDeepBrainChain\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_DBC\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eQLink\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_QLC\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eTrinity Network Credit\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_TN\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eZeepin Token\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_ZPT\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003ePikcioChain\u003c/td\u003e\n\t\t\u003ctd\u003eNeoPHP\\NeoAssets::ASSET_PKC\u003c/td\u003e\n\t\u003c/tr\u003e\n\u003c/table\u003e\n\n### The RPC\nThe 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.\n\n**Connecting to a RPC Node**\n```php\n$neo = new NeoRPC(); #use false as argument to go to testnet\n//$neo-\u003esetNode($neo-\u003egetFastestNode());\n$neo-\u003esetNode(\"http://seed5.neo.org:10332\");\n```\n\n**Asking for balance using the CityOfZion API**\n\n```php\n$neo-\u003egetBalance($testAddress);\n```\n\n**Query the account asset information, according to the account address.**\n\n```php\n$neo-\u003egetAccountState($testAddress);\n```\n\n**Query the asset information, based on the specified asset number.**\n\n```php\n$neo-\u003egetAssetState($neoAssetID);\n```\n\n**Returns the hash of the tallest block in the main chain.**\n\n```php\n$neo-\u003egetBestBlockHash();\n```\n\n**Returns the corresponding block information according to the specified index OR hash.**\n```php\n$neo-\u003egetBlock(\"0x56adb8cc0de3e4fff7b8641988c83bfca214802d263495403055efdd437234c4\");\n$neo-\u003egetBlock(1533325);\n```\n\n**Gets the number of blocks in the main chain.**\n\n```php\n$neo-\u003egetBlockCount();\n```\n\n**Calculate claim transaction amounts in order use sendrawtransaction to make a claim.**\n\n```php\n$neo-\u003egetBlockSysFee($neo-\u003egetBlockCount()-1);\n```\n\n**Returns the hash value of the corresponding block, based on the specified index.**\n\n```php\n$neo-\u003egetBlockHash($neo-\u003egetBlockCount()-1);\n```\n\n**Gets the current number of connections for the node.**\n\n```php\n$neo-\u003egetConnectionCount();\n```\n\n**Query contract information, according to the contract script hash.**\n\n```php\n$neo-\u003egetContractState(\"602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7\");\n```\n\n**Obtain the list of unconfirmed transactions in memory.**\n\n```php\n$neo-\u003egetRawMemPool();\n```\n\n**Returns the corresponding transaction information, based on the specified hash value.**\n\n```php\n$neo-\u003egetRawTransaction(\"602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7\",true);\n```\n\n**Query contract information, according to the contract script hash.**\n\n```php\n$neo-\u003egetStorage(\"c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b\", \"74657374\");\n```\n\n**Returns the corresponding transaction output information (returned change), based on the specified hash and index.**\n\n```php\n$neo-\u003egetTxOut(\"0e3c0f477d80acda1c45650b3260e2410287ef78c291f6e02f0214daca2bd2cf\",0);\n```\n\n**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)**\n```php\n$transaction_id = \"\"; //A hexadecimal string that has been serialized, after the signed transaction in the program.\n$broadcastTransaction = $neo-\u003esendRawTransaction($transaction_id);\nif ($broadcastTransaction)\n\techo \"Sent\";\nelse\n\techo \"Hasn't been sent\";\n```\n\n**Validate an address**\n```php\nif ($neo-\u003evalidateAddress(\"AXCLjFvfi47R1sKLrebbRJnqWgbcsncfro\"))\n\techo \"Address is valid\";\nelse\n\techo \"Address is not valid\";\n```\n\n### NEO Cold wallet generator\nYou 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.\n\n### CoinMarketCap integration\nNeo-PHP Features a full CoinMarketCap API integration. \n\n**To initiate the object**\n```php\n//setup coinmarketcap object\n$cmcObject = new \\NeoPHP\\CoinMarketCap();\n\n//set currency, if not set it defaults to USD\n$cmcObject-\u003esetCurrency(\"EUR\");\n```\n\n**To request the ticker**\n```php\nprint_r($cmcObject-\u003egetTicker());\n```\nArguments are start and limit. Similar to MySQL start and limit\n\n**To request the ticker for a specific currency**\n```php\n//get ticket for asset GAS\nprint_r($cmcObject-\u003egetTickerForAsset(\\NeoPHP\\Assets\\NeoAssets::ASSET_GAS));\n//get ticket for asset NEO\nprint_r($cmcObject-\u003egetTickerForAsset(\\NeoPHP\\Assets\\NeoAssets::ASSET_NEO));\n```\n[Check NEP-5 asset constants of this documentation for the right assets](#minimal-nep-5-integration)\n\n**To get global data**\n```php\n//get global data\nprint_r($cmcObject-\u003egetGlobalData());\n```\n[Check NEP-5 asset constants of this documentation for the right assets](#minimal-nep-5-integration)\n\n# Created by\n* **Benjamin de Bos** ([LinkedIn](https://www.linkedin.com/in/benjamindebos/)) - [Neodius (NEO Blockchain App)](https://github.com/Cityofzion/Neodius) \u0026 [ITSVision](https://github.com/ITSVision)\n\n* **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)\n\nCheck out [Neodius](https://github.com/ITSVision/Nodius)\n\nLicensed under [MIT License](License)\n\nEnjoy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCityOfZion%2Fneo-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCityOfZion%2Fneo-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCityOfZion%2Fneo-php/lists"}