Download the PHP package selaz/php-substrate-api without Composer

On this page you can find all versions of the php package selaz/php-substrate-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-substrate-api

php-substrate-api


PHP Substrate RPC Api

Requirement

Installation

If you want to install php-substrate-api in an existing project

if it is a new project

Basic Usage

Autoloading

Codec supports PSR-4 autoloaders.

RPC

We currently support 6 hash methods, including Blake2_128,Blake2_256,Twox128,Twox256,Twox64Concat,Blake2_128Concat。

`

When you access storage using Substrate RPC(like rpc state_getStorage , you need to provide the key associated with the item,

RPC methods that are Remote Calls available by default and allow you to interact with the actual node, query, and submit.

All rpc interface has been declare at https://github.com/gmajor-encrypt/php-substrate-api/tree/master/src/Rpc/JsonRpc

More detailed RPC documentation can be found at https://polkadot.js.org/docs/substrate/rpc

Below is a simple example of sending a token, you can use tx.. to send any transaction

`

Keyring

The Keyring allows you to perform operations on these keys (such as sign/verify) and never exposes the secretKey

to the outside world. Support ed25519(Edwards https://ed25519.cr.yp.to/) or sr25519( schnorrkel https://github.com/w3f/schnorrkel)

Contract

Metadata support

The metadata is used to describe a contract in a language agnostic way. Metadata can declare the storage and executable methods and types contained in the contract

We currently support ink metadata v0,v1,v2,v3,v4.

Deploy contract

After declaring a Contract class, you can call the new method to create a contract.

About how to build ink contract, you can refer to this https://docs.substrate.io/tutorials/smart-contracts/prepare-your-first-contract/

Below is an example.

Read Contract state

Reading the storage on the contract does not consume any gas, so anyone can read the contract.

You can simply read the contract through

Send Contract transaction

Sending contract transactions is very similar to executing extrinsic. You can simply exec the contract through

Generate contract address

Since the address algorithm of the contract is fixed, it is easy to calculate the deployed contract address

Example

More examples can refer to the test file https://github.com/gmajor-encrypt/php-substrate-api/tree/master/test/Rpc

Test

Troubleshooting

FFI error FFI\Exception: Failed loading '../php-substrate-api/vendor/gmajor/sr25519-bindings/src/Crypto/sr25519.so'

The current default sr25519-bindings FFI is for mac. Unfortunately, php composer currently does not support automatic compilation after install, so manual compilation is required. You can run this script

WebSocket\ConnectionException: Could not open socket to "127.0.0.1:9944"

In the test,The keyPair used in the test process is //Alice, ws://127.0.0.1:9944 is used by default as the node for testing SendTransaction. This node can start any private network settings by itself. You can also set the node address through environment variables.

gmajor/php-substrate-api v0.1.0 requires textalk/websocket dev-master -> found xxxx but it does not match your minimum-stability

You need set minimum-stability like this "minimum-stability": "dev" in composer.

Resources

License

The package is available as open source under the terms of the MIT License


All versions of php-substrate-api with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
textalk/websocket Version dev-master
ext-curl Version *
ext-json Version *
ext-sodium Version *
gmajor/sr25519-bindings Version dev-main
tuupola/base58 Version 2.x-dev
selaz/substrate-codec-php Version dev-master
ext-gmp Version *
netresearch/jsonmapper Version dev-master
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package selaz/php-substrate-api contains the following files

Loading the files please wait ....