The client, knowing the initial data, sends the corresponding amount with a note to the specified address with the help of his wallet.

Service

Now the backend of the service, the transaction handler, enters the work. For ease of understanding, we will use the execution of the script on crontab.

We create a php-file on the server side, then we'll assign it to cron every minute.

<?php$addr='Sg13BhANeairfS3o3w8N9sKaFrsht2bt4V';//transaction verification service address
$limit=25;//transaction limit
$offset=0;//sort out the issuance of transactions by timestamp using orderBy
$url='http://your_node_ip:6100/api/transactions?recipientId='.$addr.'&orderBy=timestamp&offset=0';//get the data and convert it to an array
$tx=json_decode(file_get_contents($url),true);/*
if the transaction is more than a limit,
offset transaction transfer pointer and get the last $ limit of transactions,
since transactions can be hundreds of thousands
*/if($tx['count']>$limit){$offset=$tx['count']-$limit;// calculation of displacement
$url='http://node_ip:6100/api/transactions?recipientId=Sg13BhANeairfS3o3w8N9sKaFrsht2bt4V&orderBy=timestamp&offset='.$offset;$tx=json_decode(file_get_contents($url),true);}// processing data
for($i=0;$i<count($tx['transactions']);$i++){print"<br>amount:".$tx['transactions'][$i]['amount']." timestamp:".$tx['transactions'][$i]['timestamp']." msg:".$tx['transactions'][$i]['vendorField']." senderId:".$tx['transactions'][$i]['senderId']." Txid:".$tx['transactions'][$i]['id'];/*
here we perform the necessary checks and writes to the database,
for example, add a balance
To save in the transaction table unique transactions,
which are also checked upon receipt,
for example txid, userid, timestamp, sum_sth, sum_coin
*//*
remember, the balance is issued in satoshi,
do not forget to convert it to exact functions
*/$sumCOIN=bcdiv($tx['transactions'][$i]['amount'],100000000,8);$set['btc_sth']=1;//course in relation to STH
$sumBTC=bcdiv($sumCOIN,$set['btc_sth'],8);//calculate the coin rate
}

Congratulations, the transaction is processed, the operation is completed.

The example does not pretend to the quality of the code, it is intended for a basic understanding of receiving payments.

Get delegates

Get delegates list.

Request

varsmartholdemApi=require("sthjs-wrapper");varparameters={"limit: Limit to show. Integer. (Integer)","offset: Offset (Integer)","orderBy: Order by field (String)"};smartholdemApi.getDelegates(parameters,(error,success,response)=>{console.log(response);});

RPC Daemon

How To Use It

All calls should be made from the server where RPC is running at ( i.e., localhost or 127.0.0.1 ).
The RPC server should never be publicly accessible.
If you wish to access smartholdem-rpc from a remote address, you can whitelist the address with --allow <address>.
Addresses allow you to use wildcards, eg. 192.168.1.* or 10.0.*.*.
If you do want to allow access from all remotes, start smartholdem-rpc with the --allow-remote commandline switch. This can be dangerous.
This is an additional library. Works as a bitcoind.

Note that if the transaction has been created via the RPC it has been stored internally, as such only the transaction id is needed to broadcast/rebroadcast it. Otherwise if created outside of this RPC server, pass the whole transaction body as the POST payload.

Note that if the transaction has been created via the RPC it has been stored internally, as such only the transaction id is needed to broadcast/rebroadcast it. Otherwise if created outside of this RPC server, pass the whole transaction body as the POST payload.

Errors

The API uses the following error codes:

When an error happens the API will return a HTTP message 400(bad request) combined with an error.