Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. declare(strict_types=1);
  3. require '../vendor/autoload.php';
  4. use Minter\MinterAPI;
  5. use Minter\SDK\MinterCoins\MinterSendCoinTx;
  6. use Minter\SDK\MinterTx;
  7.  
  8. $nodeUrl = 'https://api.minter.one/';
  9. $wallet_w1 = 'адрес откуда';
  10. $privkey_w1 = 'приватник адреса откуда';
  11. $wallet_w2 = 'адрес куда слать';
  12. $coin = 'BIP';
  13. $api = new MinterAPI($nodeUrl);
  14.  
  15. $response =  $api->getBalance($wallet_w1);
  16. $balcoin = ($response->result->balance->$coin)/10**18;
  17. echo "Sender Balance (".$coin."): ".$balcoin."\n";
  18. echo "Receiver: ".$wallet_w2."\n";
  19.  
  20. $nonce = $api->getNonce($wallet_w1);
  21. $tx = new MinterTx([
  22.     'nonce' => $nonce,
  23.     'chainId' => MinterTx::MAINNET_CHAIN_ID, // or MinterTx::TESTNET_CHAIN_ID
  24.     'gasPrice' => 1,
  25.     'gasCoin' => $coin,
  26.     'type' => MinterSendCoinTx::TYPE,
  27.     'data' => [
  28.         'coin' => $coin,
  29.         'to' => $wallet_w2,
  30.         'value' => $balcoin-0.01
  31.     ],
  32.     'payload' => '',
  33.     'serviceData' => '',
  34.     'signatureType' => MinterTx::SIGNATURE_SINGLE_TYPE // or SIGNATURE_MULTI_TYPE
  35. ]);
  36.  
  37. $txSigned = $tx->sign($privkey_w1);
  38. echo "TX signed: ".$txSigned."\n";
  39. $txResult = $api->send($txSigned);
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement