2017 © Pedro Peláez
 

library minter-php-sdk

image

minter/minter-php-sdk

  • Wednesday, July 25, 2018
  • by danil-lashin
  • Repository
  • 4 Watchers
  • 4 Stars
  • 106 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 1 Versions
  • 242 % Grown

The README.md

, (*1)

About

This is a pure PHP SDK for working with Minter blockchain, (*2)

Installing

composer require minter/minter-php-sdk

Using MinterAPI

You can get all valid responses and full documentation at Minter Node Api, (*5)

Create MinterAPI instance, (*6)

use Minter\MinterAPI;

$nodeUrl = 'https://minter-node-1.testnet.minter.network:8843/v2/'; // example of a node url

$api = new MinterAPI($nodeUrl);

getBalance

Returns coins list, balance and transaction count (for nonce) of an address., (*7)

getBalance(string $minterAddress, ?int $height = null): \stdClass, (*8)

Example
$api->getBalance('Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99')

// {"jsonrpc": "2.0", "id": "", "result": { "balance": { ... }, "transaction_count": "0"}}

getNonce

Returns next transaction number (nonce) of an address., (*9)

getNonce(string $minterAddress): int, (*10)

Example
$api->getNonce('Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99')

send

Returns the result of sending signed tx., (*11)

:warning: To ensure that transaction was successfully committed to the blockchain, you need to find the transaction by the hash and ensure that the status code equals to 0., (*12)

send(string $tx): \stdClass, (*13)

Example
$api->send('f873010101aae98a4d4e540000000000000094fe60014a6e9ac91618f5d1cab3fd58cded61ee99880de0b6b3a764000080801ca0ae0ee912484b9bf3bee785f4cbac118793799450e0de754667e2c18faa510301a04f1e4ed5fad4b489a1065dc1f5255b356ab9a2ce4b24dde35bcb9dc43aba019c')

getAddresses

Returns addresses balances., (*14)

getAddresses(array $addresses, ?int $height = null): \stdClass, (*15)

getStatus

Returns node status info., (*16)

getStatus(): \stdClass, (*17)

getValidators

Returns list of active validators., (*18)

getValidators(?int $height = null, ?int $page = 1, ?int $perPage = null): \stdClass, (*19)

estimateCoinBuy

Return estimate of buy coin transaction., (*20)

estimateCoinBuy(string $coinToSell, string $valueToBuy, string $coinToBuy, ?int $height = null, string $swapFrom): \stdClass, (*21)

estimateCoinSell

Return estimate of sell coin transaction., (*22)

estimateCoinSell(string $coinToSell, string $valueToSell, string $coinToBuy, ?int $height = null, string $swapFrom): \stdClass, (*23)

estimateCoinSellAll

Return estimate of sell coin all transaction., (*24)

estimateCoinSellAll(string $coinToSell, string $valueToSell, string $coinToBuy, ?int $height = null, string $swapFrom): \stdClass, (*25)

getCoinInfo

Returns information about coin. Note: this method does not return information about base coins (MNT and BIP)., (*26)

getCoinInfo(string $coin, ?int $height = null): \stdClass, (*27)

getBlock

Returns block data at given height., (*28)

getBlock(int $height): \stdClass, (*29)

getEvents

Returns events at given height., (*30)

getEvents(int $height): \stdClass, (*31)

getTransaction

Returns transaction info., (*32)

getTransaction(string $hash): \stdClass, (*33)

getCandidate

Returns candidate’s info by provided public_key. It will respond with 404 code if candidate is not found., (*34)

getCandidate(string $publicKey, ?int $height = null): \stdClass, (*35)

getCandidates

Returns list of candidates., (*36)

$height is optional parameter., (*37)

getCandidates(?int $height = null, ?bool $includeStakes = false): \stdClass, (*38)

estimateTxCommission

Returns estimate of transaction., (*39)

estimateTxCommission(string $tx, ?int $height = null): \stdClass, (*40)

getTransactions

Returns transactions by query., (*41)

getTransactions(string $query, ?int $page = null, ?int $perPage = null): \stdClass, (*42)

getUnconfirmedTxs

Returns unconfirmed transactions., (*43)

getUnconfirmedTxs(?int $limit = null): \stdClass, (*44)

getMaxGasPrice

Returns current max gas price., (*45)

getMaxGasPrice(?int $height = null): \stdClass, (*46)

getMinGasPrice

Returns current min gas price., (*47)

getMinGasPrice(): \stdClass, (*48)

getMissedBlocks

Returns missed blocks by validator public key., (*49)

getMissedBlocks(string $pubKey, ?int $height = null): \stdClass, (*50)

getGenesis

Returns network genesis., (*51)

getGenesis(): \stdClass, (*52)

getNetworkInfo

Returns node network information., (*53)

getNetworkInfo(): \stdClass, (*54)

getWaitlist

Returns waitlisted stakes by address, (*55)

getWaitlist(string $address, ?string $publicKey = null, ?int $height = null): \stdClass, (*56)

getWaitlist

Returns waitlisted stakes by address, (*57)

getWaitlist(string $address, ?string $publicKey = null, ?int $height = null): \stdClass, (*58)

getPriceCommissions

Returns the list of the commissions that are set up on the Minter Network, (*59)

getPriceCommissions(?int $height = null): \stdClass, (*60)

getPriceVotes

Returns the list of validators' votes for changing commissions on the network, (*61)

getPriceVotes(int $height): \stdClass, (*62)

getSwapPool

Returns entire liquidity volume of the swap pool, (*63)

getSwapPool(string $coin0, string $coin1, ?int $height = null): \stdClass, (*64)

getSwapPoolProvider

Returns liquidity volume of the swap pool provided by specified address, (*65)

getSwapPoolProvider(string $coin0, string $coin1, string $provider, ?int $height = null): \stdClass, (*66)

getLimitOrders

Returns list of limit orders by ids, (*67)

getLimitOrders(array $ids, ?int $height = null): \stdClass, (*68)

getLimitOrder

Returns limit order details by id, (*69)

getLimitOrder(int $limitOrderId, ?int $height = null): \stdClass, (*70)

getLimitOrdersByCoins

Returns limit orders related to sell and buy coins, (*71)

getLimitOrdersByCoins(string $sellCoin, string $buyCoin, int $limit = null, ?int $height = null): \stdClass, (*72)

Error handling

Example of how you can handle errors and get the response body., (*73)

use Minter\MinterAPI;
use GuzzleHttp\Exception\RequestException;

// create instance
$api = new MinterAPI('node url here');

try {
    // success response
    $response = $api->send('signed tx here');
} catch(RequestException $exception) {
    // short exception message
    $message = $exception->getMessage();

    // error response in json
    $content = $exception->getResponse()
                    ->getBody()
                    ->getContents();

    // error response as array
    $error = json_decode($content, true);                
}

Using MinterSDK

Sign transaction

Returns a signed tx., (*74)

Example
  • Sign the SendCoin transaction
  • Constructor: MinterSendCoinTx($coin, $to, $value)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSendCoinTx;

$data = new MinterSendCoinTx($coinID, 'Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99', '10');
$tx = new MinterTx($nonce, $data);

$tx->sign('your private key');

At all type of transactions you can also set optional fields: gas price, gas coin, payload, serviceData, chain id, (*75)

use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSendCoinTx;

$data = new MinterSendCoinTx($coinID, 'Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99', '10');
$tx   = (new MinterTx($nonce, $data))
   ->setChainID(MinterTx::TESTNET_CHAIN_ID)
   ->setGasPrice(1)
   ->setGasCoin(MinterTx::BASE_COIN_ID)
   ->setPayload('some payload')
   ->setServiceData('some data');

$tx->sign('your private key');
Example
  • Sign the SellCoin transaction
  • Constructor: MinterSellCoinTx($coinToSell, $valueToSell, $coinToBuy, $minimumValueToBuy)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSellCoinTx;

$data = new MinterSellCoinTx(123, '1', 321, '1');
$tx   = new MinterTx($nonce, $data);

$tx->sign('your private key');
Example
  • Sign the SellAllCoin transaction
  • Constructor: MinterSellAllCoinTx($coinToSell, $coinToBuy, $minimumValueToBuy)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSellAllCoinTx;

$data = new MinterSellAllCoinTx(123, 321, '1');
$tx   = new MinterTx($nonce, $data);

$tx->sign('your private key');
Example
  • Sign the BuyCoin transaction
  • Constructor: MinterBuyCoinTx($coinToBuy, $valueToBuy, $coinToSell, $maximumValueToSell)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterBuyCoinTx;

$data = new MinterBuyCoinTx(123, '1', 321, '1');
$tx   = new MinterTx($nonce, $data);

$tx->sign('your private key');
Example
  • Sign the CreateCoin transaction
  • Constructor: MinterCreateCoinTx($name, $symbol, $amount, $reserve, $crr, $maxSupply)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterCreateCoinTx;

$data = new MinterCreateCoinTx('TEST COIN', 'TEST', '10000', '10', 10, '10000');
$tx   = new MinterTx($nonce, $data);

$tx->sign('your private key');
Example
  • Sign the DeclareCandidacy transaction
  • Constructor: MinterDeclareCandidacyTx($address, $publicKey, $commission, $coin, $stake)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterDeclareCandidacyTx;

$data = new MinterDeclareCandidacyTx(
    'Mxa7bc33954f1ce855ed1a8c768fdd32ed927def47', 
    'Mp023853f15fc1b1073ad7a1a0d4490a3b1fadfac00f36039b6651bc4c7f52ba9c02', 
    10, 0, '10000'
);

$tx = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the Delegate transaction
  • Constructor: MinterDelegateTx($publicKey, $coin, $stake)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterDelegateTx;

$data = new MinterDelegateTx('Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43', 123, '10000');
$tx   = new MinterTx($nonce, $data);

$tx->sign('your private key');
Example
  • Sign the SetCandidateOn transaction
  • Constructor: MinterSetCandidateOnTx($publicKey)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSetCandidateOnTx;

$data = new MinterSetCandidateOnTx('Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43');
$tx   = new MinterTx($nonce, $data);

$tx->sign('your private key');
Example
  • Sign the SetCandidateOff transaction
  • Constructor: MinterSetCandidateOffTx($publicKey)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSetCandidateOffTx;

$data = new MinterSetCandidateOffTx('Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43');
$tx   = new MinterTx($nonce, $data);

$tx->sign('your private key');
Example
  • Sign the RedeemCheck transaction
  • Constructor: MinterRedeemCheckTx($check, $proof)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterRedeemCheckTx;

$data = new MinterRedeemCheckTx('your check', 'created by MinterCheck proof');
$tx   = new MinterTx($nonce, $data);

$tx->sign('your private key');
Example
  • Sign the Unbond transaction
  • Constructor: MinterUnbondTx($publicKey, $coin, $value)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterUnbondTx;

$data = new MinterUnbondTx('Mp....', 123, '10000');
$tx   = new MinterTx($nonce, $data);

$tx->sign('your private key');
Example
  • Sign the MultiSend transaction
  • Constructor: MinterMultiSendTx($list)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSendCoinTx;
use Minter\SDK\MinterCoins\MinterMultiSendTx;

$data = new MinterMultiSendTx([
    new MinterSendCoinTx(0, 'Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99', '15'),
    new MinterSendCoinTx(123, 'Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee92', '10')
]);

$tx = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the EditCandidate transaction
  • Constructor: MinterEditCandidateTx($publicKey, $rewardAddress, $ownerAddress, $controlAddress)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterEditCandidateTx;

$data = new MinterEditCandidateTx('candidate public key', 'Minter address for rewards', 'Minter address of owner', 'Minter address for control');
$tx   = new MinterTx($nonce, $data);

$tx->sign('your private key');
Example
  • Sign the CreateMultisig transaction
  • Constructor: MinterCreateMultisigTx($threshold, $weights, $addresses)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterCreateMultisigTx;

$data = new MinterCreateMultisigTx(7, [1, 3, 5], [
    'Mxee81347211c72524338f9680072af90744333143',
    'Mxee81347211c72524338f9680072af90744333145',
    'Mxee81347211c72524338f9680072af90744333144'
]);

$tx = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the SetHaltBlock transaction
  • Constructor: MinterSetHaltBlockTx($publicKey, $height)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSetHaltBlockTx;

$data = new MinterSetHaltBlockTx('your public key', 236503);
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the RecreateCoin transaction
  • Constructor: MinterRecreateCoinTx($name, $symbol, $amount, $reserve, $crr, $maxSupply)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterRecreateCoinTx;

$data = new MinterRecreateCoinTx('TEST', '10000', '10', 10000, 10, '10000');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the EditCoinOwner transaction
  • Constructor: MinterEditCoinOwnerTx($symbol, $newOwner)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterEditCoinOwnerTx;

$data = new MinterEditCoinOwnerTx('COINSYMBOL', 'Mxee81347211c72524338f9680072af90744333145');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the EditMultisig transaction
  • Constructor: MinterEditMultisigTx($threshold, $weights, $addresses)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterEditMultisigTx;

$data = new MinterEditMultisigTx(1, [1, 2], ['Mxee81347211c72524338f9680072af90744333145', 'Mxee81347211c72524338f9680072af90744333146']);
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the EditCandidatePublicKey transaction
  • Constructor: MinterEditCandidatePublicKeyTx($publicKey, $newPublicKey)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterEditCandidatePublicKeyTx;

$data = new MinterEditCandidatePublicKeyTx('public key', 'new public key....');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the AddLiquidity transaction
  • Constructor: MinterAddLiquidityTx($coin0, $coin1, $volume0, $maximumVolume1)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterAddLiquidityTx;

$data = new MinterAddLiquidityTx(0, 1, '1000', '2000');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the RemoveLiquidity transaction
  • Constructor: MinterRemoveLiquidityTx($coin0, $coin1, $liquidity, $minimumVolume0, $minimumVolume1)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterRemoveLiquidityTx;

$data = new MinterRemoveLiquidityTx(0, 1, '2000', '500', '1000');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the SellSwapPool transaction
  • Constructor: MinterSellSwapPoolTx(array $coins, $valueToSell, $minimumValueToBuy)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSellSwapPoolTx;

$data = new MinterSellSwapPoolTx([1, 2], '20',  '2');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the BuySwapPool transaction
  • Constructor: MinterBuySwapPoolTx($coins, $valueToBuy, $maximumValueToSell)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterBuySwapPoolTx;

$data = new MinterBuySwapPoolTx([2, 3], '3', '5000');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the SellAllSwapPool transaction
  • Constructor: MinterSellAllSwapPoolTx(array $coins, $minimumValueToBuy)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSellAllSwapPoolTx;

$data = new MinterSellAllSwapPoolTx([1, 4, 5], '100');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the EditCandidateCommission transaction
  • Constructor: MinterEditCandidateCommissionTx($publicKey, $commission)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterEditCandidateCommissionTx;

$data = new MinterEditCandidateCommissionTx('public key', 77);
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the MintToken transaction
  • Constructor: MinterMintTokenTx($coin, $value)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterMintTokenTx;

$data = new MinterMintTokenTx(2, '3000');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key')
Example
  • Sign the BurnToken transaction
  • Constructor: MinterBurnTokenTx($coin, $value)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterBurnTokenTx;

$data = new MinterBurnTokenTx(3, '100000');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key')
Example
  • Sign the CreateToken transaction
  • Constructor: MinterCreateTokenTx($name, $symbol, $initialAmount, $maxSupply, $mintable, $burnable)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterCreateTokenTx;

$data = new MinterCreateTokenTx('TEST COIN IS MINTABLE ONLY', 'TEST', '10000', '50000', true, false);
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key')
Example
  • Sign the RecreateToken transaction
  • Constructor: MinterRecreateTokenTx($name, $symbol, $initialAmount, $maxSupply, $mintable, $burnable)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterRecreateTokenTx;

$data = new MinterRecreateTokenTx('TEST COIN IS TURNED TO BE BURNABLE ONLY', 'TEST', '50000', '50000', false, true);
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key')
Example
  • Sign the PriceCommission transaction
  • Constructor: MinterPriceCommissionTx( $pubKey, $height, $coin, $payloadByte, $send, $buyBancor, $sellBancor, $sellAllBancor, $buyPoolBase, $buyPoolDelta, $sellPoolBase, $sellPoolDelta, $sellAllPoolBase, $sellAllPoolDelta, $createTicker3, $createTicker4, $createTicker5, $createTicker6, $createTicker7to10, $createCoin, $createToken, $recreateCoin, $recreateToken, $declareCandidacy, $delegate, $unbond, $redeemCheck, $setCandidateOn, $setCandidateOff, $createMultisig, $multisendBase, $multisendDelta, $editCandidate, $setHaltBlock, $editTickerOwner, $editMultisig, $editCandidatePublicKey, $createSwapPool, $addLiquidity, $removeLiquidity, $editCandidateCommission, $burnToken, $mintToken, $voteCommission, $voteUpdate )
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterPriceCommissionTx;

$data = new MinterPriceCommissionTx('public key', 100000,0,'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41', '42');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key');
Example
  • Sign the CreateSwapPoll transaction
  • Constructor: MinterCreateSwapPoolTx($coin0, $coin1, $volume0, $volume1)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterCreateSwapPoolTx;

$data = new MinterCreateSwapPoolTx(1, 2, '11000', '22000');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key')
Example
  • Sign the AddLimitOrder transaction
  • Constructor: MinterAddLimitOrderTx($coinToSell, $valueToSell, $coinToBuy, $valueToBuy)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterAddLimitOrderTx;

$data = new MinterAddLimitOrderTx(0, '10', 1841, '7');
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key')
Example
  • Sign the RemoveLimitOrder transaction
  • Constructor: MinterRemoveLimitOrderTx($id)
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterRemoveLimitOrderTx;

$data = new MinterRemoveLimitOrderTx($limitOrderId);
$tx   = new MinterTx($nonce, $data);
$tx->sign('your private key')

Sign transaction with multisignatures

Returns a signed tx., (*76)

Example
  • To sign transaction with multisignatures, you need to call signMultisig method and pass multisig Minter address and his private keys (in any order).
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSendCoinTx;

$data = new MinterSendCoinTx(123, 'Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99', '10');
$tx = new MinterTx($nonce, $data);

$signedTx = $tx->signMultisig('Mxdb4f4b6942cb927e8d7e3a1f602d0f1fb43b5bd2', [
    'b354c3d1d456d5a1ddd65ca05fd710117701ec69d82dac1858986049a0385af9',
    '38b7dfb77426247aed6081f769ed8f62aaec2ee2b38336110ac4f7484478dccb',
    '94c0915734f92dd66acfdc48f82b1d0b208efd544fe763386160ec30c968b4af'
])
Example
  • To get the signature of transaction (not signed transaction) you need to call createSignature
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSendCoinTx;

$data = new MinterSendCoinTx(123, 'Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99', '10');
$tx = new MinterTx($nonce, $data);

$txSignature = $tx->createSignature($privateKey);
Example
  • To sign transaction with ready signatures, you need to call signMultisigBySigns method and pass multisig Minter address and your signatures (in any order).
use Minter\SDK\MinterTx;
use Minter\SDK\MinterCoins\MinterSendCoinTx;

$data = new MinterSendCoinTx(123, 'Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99', '10');
$tx = new MinterTx($nonce, $data);

$signature1 = $tx->createSignature($privateKey1);
$signature2 = $tx->createSignature($privateKey2);
$signature3 = $tx->createSignature($privateKey3);

$signedTx = $tx->signMultisigBySigns('Mxdb4f4b6942cb927e8d7e3a1f602d0f1fb43b5bd2', [
     $signature1, $signature2, $signature3
])

Get fee of transaction

  • Calculate fee of transaction. You can get fee AFTER signing or decoding transaction.
use Minter\SDK\MinterTx;

$tx = new MinterTx(...);
$tx->getFee();

Decode transaction

Returns an array with transaction data., (*77)

Example
  • Decode transaction
use Minter\SDK\MinterTx;

$tx = MinterTx::decode('transaction raw starting from 0x...');

// $tx->getSenderAddress()
// $tx->getData()
// $tx->getNonce()
// $tx->getChainID()
// $tx->getGasPrice()
// $tx->getPayload()
// $tx->getSignatureData()

Create Minter Check

Example
  • Create check
use Minter\SDK\MinterCheck;

$check = new MinterCheck([
    'nonce' => $nonce,
    'chainId' => MinterTx::MAINNET_CHAIN_ID, // or MinterTx::TESTNET_CHAIN_ID
    'dueBlock' => 999999,
    'coin' => 'MNT',
    'value' => '10',
    'gasCoin' => 'MNT'
], 'your pass phrase');

echo $check->sign('your private key here'); 

// Mc.......

  • Create proof
use Minter\SDK\MinterCheck;

$check = new MinterCheck('your Minter address here', 'your pass phrase');

echo $check->createProof(); 
  • Decode check
use Minter\SDK\MinterCheck;

$check = new MinterCheck('your Minter check here');

$check->getBody();  // check body

$check->getOwnerAddress(); // check owner address

Minter Wallet

Example
  • Create wallet.
use Minter\SDK\MinterWallet;

$wallet = new MinterWallet();

// $wallet->getPublicKey();
// $wallet->getPrivateKey();
// $wallet->getMnemonic();
// $wallet->getAddress();
  • Create wallet from mnemonic
use Minter\SDK\MinterWallet;

$wallet = MinterWallet::createFromMnemonic($mnemonic);
  • Create wallet from private key
use Minter\SDK\MinterWallet;

$wallet = MinterWallet::createFromPrivate($privateKey);
Example
  • Create Minter deep link.
  • You can pass data of any Minter transaction to the constructor.
use Minter\SDK\MinterDeepLink;
use Minter\SDK\MinterCoins\MinterSendCoinTx;

$txData = new MinterSendCoinTx(123, 'Mx18467bbb64a8edf890201d526c35957d82be3d95', '1.23456789');
$link   = new MinterDeepLink($txData);
$link->encode(); // returns encoded link as string
  • You can define optional fields such as host, payload, nonce, gas price, gas coin, check password.
use Minter\SDK\MinterDeepLink;
use Minter\SDK\MinterCoins\MinterSendCoinTx;

$txData = new MinterSendCoinTx(123, 'Mx18467bbb64a8edf890201d526c35957d82be3d95', '1.23456789');
$link   = new MinterDeepLink($txData);

$link->setPayload('Hello World')
    ->setNonce($nonce)
    ->setGasPrice($gasPrice)
    ->setGasCoin($gasCoin)
    ->setHost('https://testnet.bip.to/tx')
    ->setPassword('some check password');

$link->encode(); // returns encoded link as string

Tests

To run unit tests:, (*78)

vendor/bin/phpunit tests

The Versions