Minter Blockchain PHP SDK

Overview

About

This is a pure PHP SDK for working with Minter blockchain

Installing

composer require minter/minter-php-sdk

Using MinterAPI

You can get all valid responses and full documentation at Minter Node Api

Create MinterAPI instance

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.

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

Example
$api->getBalance('Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99')

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

getNonce

Returns next transaction number (nonce) of an address.

getNonce(string $minterAddress): int

Example
$api->getNonce('Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99')

send

Returns the result of sending signed tx.

⚠️ 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.

send(string $tx): \stdClass

Example
$api->send('f873010101aae98a4d4e540000000000000094fe60014a6e9ac91618f5d1cab3fd58cded61ee99880de0b6b3a764000080801ca0ae0ee912484b9bf3bee785f4cbac118793799450e0de754667e2c18faa510301a04f1e4ed5fad4b489a1065dc1f5255b356ab9a2ce4b24dde35bcb9dc43aba019c')

getAddresses

Returns addresses balances.

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

getStatus

Returns node status info.

getStatus(): \stdClass

getValidators

Returns list of active validators.

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

estimateCoinBuy

Return estimate of buy coin transaction.

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

estimateCoinSell

Return estimate of sell coin transaction.

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

estimateCoinSellAll

Return estimate of sell coin all transaction.

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

getCoinInfo

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

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

getBlock

Returns block data at given height.

getBlock(int $height): \stdClass

getEvents

Returns events at given height.

getEvents(int $height): \stdClass

getTransaction

Returns transaction info.

getTransaction(string $hash): \stdClass

getCandidate

Returns candidate’s info by provided public_key. It will respond with 404 code if candidate is not found.

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

getCandidates

Returns list of candidates.

$height is optional parameter.

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

estimateTxCommission

Returns estimate of transaction.

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

getTransactions

Returns transactions by query.

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

getUnconfirmedTxs

Returns unconfirmed transactions.

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

getMaxGasPrice

Returns current max gas price.

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

getMinGasPrice

Returns current min gas price.

getMinGasPrice(): \stdClass

getMissedBlocks

Returns missed blocks by validator public key.

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

getGenesis

Returns network genesis.

getGenesis(): \stdClass

getNetworkInfo

Returns node network information.

getNetworkInfo(): \stdClass

getWaitlist

Returns waitlisted stakes by address

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

getWaitlist

Returns waitlisted stakes by address

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

getPriceCommissions

Returns the list of the commissions that are set up on the Minter Network

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

getPriceVotes

Returns the list of validators' votes for changing commissions on the network

getPriceVotes(int $height): \stdClass

getSwapPool

Returns entire liquidity volume of the swap pool

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

getSwapPoolProvider

Returns liquidity volume of the swap pool provided by specified address

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

Error handling

Example of how you can handle errors and get the response body.

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.

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

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')

Sign transaction with multisignatures

Returns a signed tx.

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.

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);

Minter Link

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:

vendor/bin/phpunit tests
Comments
  • RedeemCheck

    RedeemCheck

    RedeemCheck does not work, or example is incorrect.

    Firstly MinterTx->data->proof must be in hex instead of string, which is described in the example.

    $tx = new MinterTx([
        'nonce' => $nonce,
        'gasPrice' => 1,
        'gasCoin' => 'MNT',
        'type' => MinterRedeemCheckTx::TYPE,
        'data' => [
            'check' => $check_id,
            'proof' => str2hex($check_proof)
        ],
        'payload' => '',
        'serviceData' => '',
        'signatureType' => MinterTx::SIGNATURE_SINGLE_TYPE // or SIGNATURE_MULTI_TYPE
    ]);
    
    $sign = $tx->sign($privateKey);
    

    But even with correct tx data I receive the following error response:

    string(254) "{
      "jsonrpc": "2.0",
      "id": "",
      "error": {
        "code": 412,
        "message": "Check tx error",
        "tx_result": {
          "code": 106,
          "log": "rlp: input string too short for [65]uint8, decoding into (transaction.RedeemCheckData).Proof"
        }
      }
    }"
    
    opened by HarpyWar 4
  • MinterDelegateTx should accept PIPs as stake amount, not BIP

    MinterDelegateTx should accept PIPs as stake amount, not BIP

    It should be bigint, as stated in the docs.

    Now, to delegate 1 BIP the payload is:

    'data' => [
        'stake' => '1',
    ],
    

    Should be:

    'data' => [
        'stake' => '1000000000000000000',
    ],
    
    opened by ingria 4
  • Delegating coins: {

    Delegating coins: {"code":106,"log":"Check tx error: rlp: non-canonical integer (leading zero bytes) for *big.Int, decoding into (transact (truncated...) in /root/minter-php-sdk/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113

    Очень редко появляется такая ошибка при делегации монет. может пройти 300 прогонов без ошибок, а может на 100ом свалиться:

    Try #:146
    Date: Fri, 27 Jul 2018 11:09:04 +0300
    array(4) {
      ["address"]=>
      string(42) "Mxa90dfa4e400fcf0c7933d17c3b10cde4eb6b364b"
      ["private_key"]=>
      string(64) "4f20715bbb5b9a557ea108853c2d57f0784ed4be19aef427c4e49b0974740f1b"
      ["mnemonic"]=>
      string(73) "allow core soon family trouble initial sword oak romance treat awake much"
      ["seed"]=>
      string(128) "10678880521ed76d8eab49968d385780ed6e303d491fe586ea96ab678f832ae23f3126d91d2dae87e2f49c00f702ab296620ed95b4ceeadc54b851f8d006b0bd"
    }
    Sender: Mx0a46253f2256d6b2e2872e0682eb86d8fb20789f
    Sender Balance (MNT): 981440129537174424934
    Receiver: Mxa90dfa4e400fcf0c7933d17c3b10cde4eb6b364b
    Fee between accounts: 10000000000000000
    TX signed: f8808203cb018a4d4e540000000000000001aae98a4d4e540000000000000094a90dfa4e400fcf0c7933d17c3b10cde4eb6b364b880f43fc2c04ee000080801ca04fd60db4d4c0d64c6169e0809dc39a9c3d2046769a7185b1311cd7530f236796a0467da99a6db0df303065782ba763f2cb64bfbfe04b8465a18d14d5eb20bf31f3
    Transaction Code: 0; TransactionResult: Mte8cfafa5f07aefdd73e60b022977d66d050f641e
    Delegation:
    Delegate Balance (MNT): 1100000000000000000
    Delegation Fee: 100000000000000000
    TX signed: f87901018a4d4e540000000000000007b6f5a0c6d5ebbf6092d31585cf365c8079b9e77a67fcd56c2f8084172c6d8634c6a83a8a4d4e5400000000000000880de0b6b3a764000080801ca086efc0693c33721c5d9ca690e3e3d6a2adbba95e961dec574e59c0fa43e58d658f000400000f00000000000000005700
    PHP Fatal error:  Uncaught GuzzleHttp\Exception\ServerException: Server error: `POST http://188.120.239.162:8841/api/sendTransaction` resulted in a `500 Internal Server Error` response:
    {"code":106,"log":"Check tx error: rlp: non-canonical integer (leading zero bytes) for *big.Int, decoding into (transact (truncated...)
     in /root/minter-php-sdk/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
    Stack trace:
    #0 /root/minter-php-sdk/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
    #1 /root/minter-php-sdk/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
    #2 /root/minter-php-sdk/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
    #3 /root/minter-php-sdk/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{cl in /root/minter-php-sdk/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113
    
    

    Код программы https://pastebin.com/1wDyhPJY Лог прогона с 74 попытки: https://pastebin.com/6wNyTYYB @icopuppy

    opened by vanlikk 3
  • PHP Fatal error:  Uncaught GuzzleHttp\Exception\ServerException: Server error: `POST http://188.120.239.162:8841/api/sendTransaction` resulted in a `500 Internal Server Error` response: {

    PHP Fatal error: Uncaught GuzzleHttp\Exception\ServerException: Server error: `POST http://188.120.239.162:8841/api/sendTransaction` resulted in a `500 Internal Server Error` response: {"code":106,"log":"Check tx error: incorrect tx signature"}

    Код скрипта: https://pastebin.com/RLn3AFAS Полный стектрейс прогона скрипта: https://pastebin.com/ZEiHZySr

    Последовательно выполняется отправка транзакций с одного фиксированного адреса на другой, но на 49ой итерации скрипт валится с ошибкой:

    PHP Fatal error:  Uncaught GuzzleHttp\Exception\ServerException: Server error: `POST http://188.120.239.162:8841/api/sendTransaction` resulted in a `500 Internal Server Error` response:
    {"code":106,"log":"Check tx error: incorrect tx signature"}
    
     in /root/minter-php-sdk/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
    Stack trace:
    #0 /root/minter-php-sdk/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
    #1 /root/minter-php-sdk/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
    #2 /root/minter-php-sdk/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
    #3 /root/minter-php-sdk/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
    #4 /root/minter-php-sdk/vendor/guzzlehttp/promises/src/Promise.php in /root/minter-php-sdk/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113
    [root@mintervalidator src]#
    
    
    

    @icoppupy

    opened by vanlikk 3
  • "incorrect PubKey"

    Пытаюсь сделать DeclareCandidacy . В данных делаю: 'pubkey' => SDK\MinterWallet::privateToPublic($arWallet_Node['private_key']),

    Ответ от сервера {"code":407,"log":"Check tx error: Incorrect PubKey"}

    Это появилось после сегодняшнего обновления. До обновления сервер принимал ключ нормально!

    opened by azimuth0x28 3
  • Error in MinterSendCoinTx

    Error in MinterSendCoinTx

    Hello. Try to create MinterSendCoinTx and got an error: $data = new MinterSendCoinTx(0, $to, (string)$amount);

    2020-10-21 08:32:17 [95.217.152.178][-][-][error][yii\base\ErrorException:64] yii\base\ErrorException: Declaration of Minter\SDK\MinterCoins\MinterSendCoinTx::encode(): array must be compatible with Minter\SDK\MinterCoins\MinterCoinTx::encode(): Web3p\RLP\Buffer in /var/www/cripto_service/vendor/minter/minter-php-sdk/src/Minter/SDK/MinterCoins/MinterSendCoinTx.php:13

    PHP 7.2.24-1+0-20191026.31+debian9-1.gbpbbacde (cli) (built: Oct 26 2019 14:18:28) ( NTS ) "minter/minter-php-sdk": "dev-master"

    opened by oggy95 2
  • Напишите, пожалуйста, понятную документацию!

    Напишите, пожалуйста, понятную документацию!

    getTransactions Returns transactions by query.

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

    Что за строка query? Почему не указали примера? Что это такое?

    opened by glowfisch8lan 1
  • Why is certificate verification disabled?

    Why is certificate verification disabled?

    Why is certificate verification disabled? https://github.com/MinterTeam/minter-php-sdk/blob/88468327b61599116f902299b4ec8e6b3808487f/src/Minter/MinterAPI.php#L51

    opened by counters 1
  • Call to undefined function BIP\Library\gmp_strval()

    Call to undefined function BIP\Library\gmp_strval()

    Work with laravel. From Console is work ok.

    But when i past to request in controller is given error

    "message": "Call to undefined function BIP\Library\gmp_strval()", "exception": "Symfony\Component\Debug\Exception\FatalThrowableError", "file": "/var/www/html/vendor/minter/minter-php-bip-44/src/BIP/Library/Helper.php", "line": 27, "trace": [ { "file": "/var/www/html/vendor/minter/minter-php-bip-44/src/BIP/HDKey.php", "line": 289, "function": "hex_decode", "class": "BIP\Library\Helper", "type": "::" }, { "file": "/var/www/html/vendor/minter/minter-php-bip-44/src/BIP/HDKey.php", "line": 185, "function": "computeFingerprint", "class": "BIP\HDKey", "type": "->" }, { "file": "/var/www/html/vendor/minter/minter-php-bip-44/src/BIP/HDKey.php", "line": 62, "function": "generateKeysFromPrivate", "class": "BIP\HDKey", "type": "->" }, { "file": "/var/www/html/vendor/minter/minter-php-bip-44/src/BIP/BIP44.php", "line": 28, "function": "__construct", "class": "BIP\HDKey", "type": "->" }, { "file": "/var/www/html/vendor/minter/minter-php-sdk/src/Minter/SDK/MinterWallet.php", "line": 110, "function": "fromMasterSeed", "class": "BIP\BIP44", "type": "::" }, { "file": "/var/www/html/app/Http/Controllers/Api/MinterController.php", "line": 96, "function": "seedToPrivateKey", "class": "Minter\SDK\MinterWallet", "type": "::" }, { "function": "outMinter", "class": "App\Http\Controllers\Api\MinterController", "type": "->" },

    opened by pblaravel 1
  • Add dependency Injection to MinterApi constructor

    Add dependency Injection to MinterApi constructor

    Please add Client DI to constructor.

    // Minter\MinterAPI

         /**
         * MinterAPI constructor.
         * @param $nodeUrl
         */
        public function __construct($nodeUrl)
        {
          if (is_string($nodeUrl)){
            $this->setApiUrl($nodeUrl);
          }
          elseif ($nodeUrl instanceof \GuzzleHttp\Client)
          {
            $this->setClient($nodeUrl);
          }
    
        }
    
        protected function setClient(\GuzzleHttp\Client $client): void
        {
          $this->client = $client;
        }
    
    opened by azimuth0x28 1
  • getHash() Не верно рассчитывает хеш

    getHash() Не верно рассчитывает хеш

    Сделал транзакцию , получил Хеш в SDK PHP Mt52623a967982504f4a156d2789e2da7b627684f9

    Но в блокчейне эта транзакция имеет иной хеш https://testnet.explorer.minter.network/transactions/Mt2aae4013f18b6e77cb078629f7e5ac565b8bc2c1

    opened by azimuth0x28 1
Releases(v3.7.0)
Owner
Minter
Minter is a digital assets marketplace allowing anyone to buy, sell, send, and spend BTC, ETH, BIP, USDC, gold, oil, stocks, and much more.
Minter
Official repository of the AWS SDK for PHP (@awsforphp)

AWS SDK for PHP - Version 3 The AWS SDK for PHP makes it easy for developers to access Amazon Web Services in their PHP code, and build robust applica

Amazon Web Services 5.7k Jan 1, 2023
Mailgun's Official SDK for PHP

Mailgun PHP client This is the Mailgun PHP SDK. This SDK contains methods for easily interacting with the Mailgun API. Below are examples to get you s

Mailgun Team 1k Dec 23, 2022
A Laravel package to help integrate Shopware PHP SDK much more easier

Shopware 6 Laravel SDK A Laravel package to help integrate Shopware PHP SDK much more easier Installation Install with Composer composer require sas/s

Shape & Shift 16 Nov 3, 2022
The official PHP SDK for Webmarketer (app.webmarketer.io)

PHP SDK for Webmarketer The official PHP SDK for Webmarketer (app.webmarketer.io). Install To add this package, your project must meet several require

Webmarketer 5 Dec 13, 2021
A PHP SDK for the GlobalSmartOTP API.

GlobalSmartOTP PHP SDK A PHP SDK for the GlobalSmartOTP API. Requirements PHP 7.4 or higher cURL Installation $ git clone [email protected]:GlobalSmartOT

GlobalSmartOTP 4 Oct 2, 2022
Fatture in Cloud SDK (Software Development Kit) for PHP

FattureInCloud PHP SDK Request informations In every request description you will be able to find some additional informations about context, permissi

Fatture in Cloud 25 Dec 5, 2022
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.

Telegram Bot API - PHP SDK Telegram Bot PHP SDK lets you develop Telegram Bots in PHP easily! Supports Laravel out of the box. Telegram Bot API is an

Irfaq Syed 2.5k Jan 6, 2023
Explicador e2Payments PHP SDK

This package seeks to help php developers implement the e2Payments APIs without much hustle. It is based on the REST API whose documentation

Explicador 5 Oct 26, 2022
Official PHP SDK for interacting with the Knock API.

Knock PHP library Documentation See the documentation for PHP usage examples

Knock 4 Dec 16, 2022
Laravel wrapper for the Facebook Graph PHP 8 SDK

Laravel Facebook Graph SDK Installation Getting started with Laravel Facebook Graph is easy - first, install the package via composer composer require

Joel Butcher 44 Dec 8, 2022
OneSignal PHP SDK

OneSignal SDK for PHP developers with fluent API and supports Laravel / Lumen out of the box.

Lawrence Onah 4 Nov 8, 2022
2c2p payment gateway Redirect PHP-SDK

2c2p payment gateway Redirect PHP-SDK

Bilions 2 Oct 1, 2022
可能是基于 hyperf 的最优雅的支付宝、微信支付 SDK 了

当前组件整体处于 beta 阶段 运行环境 php >= 7.3 composer hyperf >= 2.1 安装 composer require yansongda/hyperf-pay:~1.0.0 说明 发布配置文件 php bin/hyperf.php vendor:publish ya

yansongda 44 Dec 8, 2022
SDK for latest version of Telegram bots API

SDK for latest version of Telegram bots API (from April 24, 2020) Using Examples Installing composer require "DiyorbekUz/Telelib: dev-master" Init bot

Diyorbek 2 Sep 5, 2021
API SDK for OpenTrade Commerce API: Taobao, Alibaba, JD, 1688, Aliexpress, Ebay.

OtapiPhpClient Create Client $client = new OtClient($key, $secret, $lang); key (Access Key) secret (Secret for access key) language (2 symbol lang id

OpenTrade Commerce 5 Sep 20, 2022
Laravel SDK for Sentry

Sentry for Laravel Laravel integration for Sentry. Laravel Version Compatibility Laravel <= 4.2.x is supported until 0.8.x Laravel <= 5.7.x on PHP <=

Sentry 1.1k Dec 30, 2022
Universal payments API SDK (UNOFFICIAL QIWI CLIENT)

Qiwi Php Client Especially for ?? Zorra Telecom and ?? Everyone else Привет Attention: At the moment the number of methods is very limited, they will

Ivan Terentev 2 Oct 25, 2022
⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.

Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC. This project is a work-in-progress. Code and docume

Web3 PHP 665 Dec 23, 2022
Lightweight PHP library for WhatsApp API to send the whatsapp messages in PHP provided by ultramsg.com

Ultramsg.com WhatsApp API PHP SDK Lightweight PHP library for WhatsApp API to send the whatsappp messages in PHP provided by Ultramsg.com Installation

Ultramsg 117 Dec 26, 2022