I like the speed of development and excellent portability. It’s great to always have a ready-to-solve-tool at hand.
It was quite disappointing when I first encountered the domestic blockchain and found that there was no ready SDK in PHP available. Well, I had to write it myself.
At first, I had to use for signing transactions. So, to manage three addresses, I had to run three nodes… It was a pathetic sight, although it solved some problems. Until I realized that relying on nodes was a dead-end. Firstly, due to limited functionality , and secondly, due to speed (in those days, nodes were very slow).
I started two parallel projects. One was to create a blockchain explorer that would be fast and completely independent of node APIs. The second was to gather all functions for working with the Waves Platform in one place. This is how the projects and .
The first step behind the scenes of the Waves blockchain was . It wasn’t easy, but I managed to write an independent calculation of all balances and even found a bug in the calculations on the original nodes ( by the way, they have, and they pay for found errors). You can learn more about the functionality of the w8io explorer in this topic:
During the process of working on w8io, I already had doubts, but when the work came to a logical end and I started creating the SDK, the doubts were confirmed. I couldn’t find certain functions anywhere, including the most important cryptographic ones. That's when I started building my own bricks for the foundation. Thus were born: for encoding in base58 (actually for encoding any alphabet in any), for creating and verifying compatible signatures (with options ), for calculating one of the hashes (which was available only starting from PHP 7.2) etc.
Here I must thank for several valuable pieces of advice that guided me towards instead of the familiar but outdated include files.
A couple of months later , came out of and is now ready to work with all standard functionalities of the Waves platform. All available in Transactions can be easily created, signed, and sent by a single package that works on all 64-bit versions of PHP starting from 5.6.
Integrating WavesKit into your project:
composer require deemru/waveskitUsage:
use deemruWavesKit;
$wk = new WavesKit( 'T' );
$wk->setSeed( 'manage manual recall harvest series desert melt police rose hollow moral pledge kitten position add' );
$tx = $wk->txBroadcast( $wk->txSign( $wk->txTransfer( 'test', 1 ) ) );
$tx = $wk->ensure( $tx );In the example above, we create a WavesKit object that operates in the test network 'T'. We set the seed phrase from which the keys and account address based on the public key are automatically computed. Next, we create a transfer transaction of 0.00000001 Waves from the automatically computed address to the alias address 'test', sign it with the private key, and send it to the network. After that, we ensure that the transaction is successfully confirmed by the network.
Working with transactions is focused in . To better understand how to work with transactions, you can study or directly refer to visual examples in .
Since WavesKit has developed under real use conditions, it already has advanced features. The first killer feature is the , which monitors reaching the required level of confidence that the transaction has not been lost, but rather has been confirmed and has reached the necessary number of confirmations in the network.
Another bulletproof mechanism is how WavesKit communicates with nodes. Under optimal conditions, the framework only works with the main node, maintaining a constant connection with it, but in case of errors, it can automatically switch to backups. If you set an array of backup nodes, you can call the function to determine the best node as the main one based on the maximum value of the current height and response speed. Now add to this an internal request cache and feel the care for both users and node owners.
One of the latest advanced mechanisms is the function It emerged from the need to respond to incoming transactions in real time. This function completely addresses all nuances related to transaction processing in the blockchain. No more pain, just set your callback function with the desired options and wait for new transactions that will trigger your processes. For example, another one of my projects is entirely built around this function, and you can easily explore how it works right .
I love open source; it is one of humanity's greatest achievements. Since I am the sole developer and have reached a state where all my needs are met, I invite you to use and contribute to .
Source: habr.com
