PHP implementation of official NEM API : https://nemproject.github.io/
- First you should install your own NIS server on Ubuntu/Debian, following instructions: https://forum.nem.io/t/nem-supernode-command-line-tutorial-for-debian-8-4/2211
mkdir nem-php
cd nem-php
clone https://github.com/Dmatafonov/nem-php.git .
require_once 'nem-php/nem-php.php';
$config = [
'net' => 'mainnet', //testnet or mijin
'nis_address' => 'http://127.0.0.1',
'private' => 'xxx', //put your private key from nem wallet
'public' => 'xxx', //put your public key from nem wallet
'security_check' => true //leave it true if you are not sure
];
$nemPhp = new NemPhp($config); //Get library
print_r($nemPhp->heartbit()); //Check if it's working
//Prepare transaction
$nemPhp->prepareTransaction(
1, //How much XEM to send
0, //Put higher fee if you want, otherwise leave it zero so minimum fee will be taken off
'NDNRSW-FEQ256-HQLUYT-L6SOS3-RYHEJK-BLOWL2-C6MJ' //adress where to send
);
//You can check your future transaction before sending
print_r($nemPhp->transaction);
//Or get estimated transaction fee in microXEM (actual amount in XEM will be divided vy 1000000)
echo $nemPhp->transaction['fee'];
//And commit transaction to the network (you shoud almost immidiately hear 'dink' sound from you wallet
$result = $nemPhp->commitTransaction();
//See how its gone
print_r($result);
//Prepare transaction
$nemPhp->prepareTransaction(
1, //How much mosaics to send
0, //Put higher fee if you want, otherwise leave it zero so minimum fee will be taken off
'NDNRSW-FEQ256-HQLUYT-L6SOS3-RYHEJK-BLOWL2-C6MJ' //adress where to send
);
//Add mosaics to your transaction
$nemPhp->addMosaicToTransaction(
'zeus-test', //namespace
'aapl', //name
1 //quantity
);
//You can check your future transaction before sending
print_r($nemPhp->transaction);
//Or get estimated transaction fee in microXEM (actual amount in XEM will be divided vy 1000000)
echo $nemPhp->transaction['fee'];
//And commit transaction to the network (you shoud almost immidiately hear 'dink' sound from you wallet
$result = $nemPhp->commitTransaction();
//See how its gone
print_r($result);
$mosaic = $nemPhp->fetchMosaicInfo('zeus-test', 'aaple');
$mosaics = $nemPhp->fetchAllMosaics('zeus-test');
//Get 25 most recent transactions
$transactions = $nemPhp->accountTransfersIncoming(
null, //address - if ommitted, then address is taken from public key
null, //Get 25 transactions that appeared directly before the transaction with paricular id
null //Get 25 transactions that appeared directly before the transaction with paricular hash
);
//Get 25 transactions that appeared directly before the transaction with paricular id
$transactions = $nemPhp->accountTransfersIncoming(null, $id);
//Get 25 transactions that appeared directly before the transaction with paricular hash
$transactions = $nemPhp->accountTransfersIncoming(null, null, '674cf29a76c2e86368f8ff6608db731fa6aa54cf4bfdf4efe6c65c946eb3ae01');
//Get 25 most recent transactions
$transactions = $nemPhp->accountTransfersOutgoing(
null, //address - if ommitted, then address is taken from public key
null, //Get 25 transactions that appeared directly before the transaction with paricular id
null //Get 25 transactions that appeared directly before the transaction with paricular hash
);
//Get 25 most recent transactions
$transactions = $nemPhp->accountTransfersAll(
null, //address - if ommitted, then address is taken from public key
null, //Get 25 transactions that appeared directly before the transaction with paricular id
null //Get 25 transactions that appeared directly before the transaction with paricular hash
);
//Get 25 most recent transactions
$transactions = $nemPhp->accountUnconfirmedTransactions(
null, //address - if ommitted, then address is taken from public key
);
//Account related calls
->status(); //get account status
->accountGenerate(); //generate new account
->accountGet(); //request account data
->accountGetFromPublicKey($public = null); //same as above, ut you can put someone's public key to gind out his address and how rich he is
->accountGetForwarded(); //Requesting the original account data for a delegate account
->accountStatus(); //short account status
->localAccountTransfersIncoming($id = null, $hash = null); //same as accountTransfersIncoming but with messages decrypted
->localAccountTransfersOutgoing($id = null, $hash = null); //same as accountTransfersOutgoing but with messages decrypted
->localAccountTransfersAll($id = null, $hash = null); //same as accountTransfersAll but with messages decrypted
->accountHarvests($address = null, $hash = null); //Requesting harvest info data for an account
->accountImportances(); //Retrieving account importances for accounts
->accountNamespacePage(); //Retrieving namespaces that an account owns
->accountMosaicDefinitionPage($address = null, $parent = null, $id = null); //raw mosaic definition, same as fetchMosaicInfo
->accountMosaicOwned($address = null); //Retrieving mosaics that an account owns
->accountUnlock(); //Unlocking accounts
->accountLock(); //Locking accounts
->accountUnlockedInfo(); //Retrieving the unlock info
->accountHistoricalGet($address = null, $startHeight, $endHeight, $increment = 1000); //Retrieving historical account data
//Blockchain related calls
->chainHeight(); //Block chain height
->chainScore(); //Block chain score
->chainLastBlock(); //Last block of the block chain score
->blockAtPublic($blockHeight); //Getting a block with a given height
->localChainBlocksAfter($blockHeight); //Getting part of a chain
//Namespaces
->namespaceRootPage(); //Retrieving root namespaces
->namespaceRequest($id); //Retrieving a specific namespace
XEM: NDNRSW-FEQ256-HQLUYT-L6SOS3-RYHEJK-BLOWL2-C6MJ