SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | - | require '../../vendor/autoload.php'; |
| 2 | + | declare(strict_types=1); |
| 3 | - | use Minter\SDK\MinterWallet; |
| 3 | + | require '../vendor/autoload.php'; |
| 4 | use Minter\MinterAPI; | |
| 5 | - | $mnemonic = MinterWallet::generateMnemonic(); |
| 5 | + | use Minter\SDK\MinterCoins\MinterSendCoinTx; |
| 6 | - | $seed = MinterWallet::mnemonicToSeed($mnemonic); |
| 6 | + | use Minter\SDK\MinterTx; |
| 7 | - | $privateKey = MinterWallet::seedToPrivateKey($seed); |
| 7 | + | |
| 8 | - | $publicKey = MinterWallet::privateToPublic($privateKey); |
| 8 | + | $nodeUrl = 'https://api.minter.one/'; |
| 9 | - | $address = MinterWallet::getAddressFromPublicKey($publicKey); |
| 9 | + | $wallet_w1 = 'адрес откуда'; |
| 10 | $privkey_w1 = 'приватник адреса откуда'; | |
| 11 | - | echo $address."\n"; |
| 11 | + | $wallet_w2 = 'адрес куда слать'; |
| 12 | - | echo $privateKey."\n"; |
| 12 | + | $coin = 'BIP'; |
| 13 | - | echo $mnemonic."\n"; |
| 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 | ?> |