Skip to main content

PHP RPC Lib Follow up

  • Team Name: gmajor
  • Payment Address: 0xC3094f0ddce699a1Ad9Ef2621DF68Cd297a4c44F (Dai)
  • Level: 1

Project Overview 📄​

Overview​

As Gavin mentioned in this CoinDesk article, WebAssembly is the future of smart contracts.

However, WebAssembly, as the main Smart Contract in the substrate ecosystem, lacks the necessary infrastructure. Except for the lib of contracts provided by polkadot.js, there are no more third parties that can query the contract storage and interact with the package.

PHP is one of the most popular development languages in the world, PHP is used by 77.8% of all the websites whose server-side programming language(https://w3techs.com/technologies/details/pl-php).

Traditional PHP Website developers will lack the necessary SDK if they come into contact with the substrate, However, the lack of support for contracts in the current php-substrate-api makes it very difficult to use PHP as a development language to interact with the substrate.

Therefore, this proposal is an extension of php-substrate-api to improve the practicability of this package further and increase support for smart contracts.

Project Details​

  • Abi encode & decode, support contract metadata v0,v1,v2,v3,v4, this will be used to read and write smart contracts

  • Deploy wasm smart contract

Example

$api = new SubstrateRpc("websocket_or_http_url");
$api->rpc->contracts->new("wasm_code", "gas limit","value");
  • Read contract values

Example

$api = new SubstrateRpc("websocket_or_http_url");
$api->rpc->contracts->balanceOf("from","contract");
  • Send Contract transaction

Example

$api = new SubstrateRpc("websocket_or_http_url");
$signer = new SubstrateRpc\Util\Keyring\Signer("privatekey");// or HD
$api->setSigner($signer);
$tx = $api->tx->contracts->transfer("to_address", 10000);
$tx->signAndSend();

Ecosystem Fit​

CIt can help PHP language developers easily access the substrate (polkadot) ecology

Team 👥​

Team members​

  • gmajor

Contact​

individual

Team's experience​

I have many years of php development experience and nearly five years of blockchain development experience, familiar with PHP, GOLANG, PYTHON, Nodejs, Rust

Team Code Repos​

https://github.com/gmajor-encrypt/php-scale-codec

https://github.com/gmajor-encrypt/php-substrate-api

https://github.com/gmajor-encrypt/sr25519-bindings

https://github.com/gmajor-encrypt/scale-codec-comparator

Development Status 📖​

Not yet

Development Roadmap 🔩​

Overview​

  • Total Estimated Duration: 1.5 months
  • Total Costs: 10000 DAI

Milestone 1​

  • Estimated duration: 1.5 month
  • FTE: 1
  • Costs: 10000 DAI
NumberDeliverableSpecification
0a.LicenseMIT
0b.DocumentationDocumentation on how to use this lib and how to test
1.ABIAbi encode & decode, contract metadata v0,v1,v2,v3,v4 will be supported
2.Deployphp-substrate-api implement new method of deploy wasm smart contract
3.Read contractImplement method read contract values and decode as human readable, similar to api-contract-read
4.Write contractImplement method send Contract transaction, similar to api-contract-tx
5.TestIncluding all the unit tests mentioned above
6.ExampleProvide some simple examples of using this lib
7.PackagistSubmit to Packagist for composer to use
8.Github actionAuto Test when new commit

Future Plans​

This milestone still lacks support for smart contract verification, there is no better solution at present, and will be supported after research