Bened API Doc
Basic API methods with examples.
1.Get Block
Getting a block
Request
Response
Example
Request:
?requestType=getBlock
&block=8455642159445842600

  • requestType is getBlock
  • block is the block ID (optional)
  • height is the block height (optional if block provided)
  • timestamp is the timestamp (in seconds since the genesis block) of the block (optional if height provided)
  • includeTransactions is true to include transaction details (optional)
  • includeExecutedPhased is true to include approved and executed phased transactions (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Note: block overrides height which overrides timestamp.
Response:
  • previousBlockHash (S) is the 32-byte hash of the previous block
  • payloadLength (N) is the length (in bytes) of all transactions included in the block
  • totalAmountNQT (S) is the total amount (in NQT) of the transactions in the block
  • generationSignature (S) is the 32-byte generation signature of the generating account
  • generator (S) is the generating account number
  • generatorPublicKey (S) is the 32-byte public key of the generating account
  • baseTarget (S) is the base target for the next block generation
  • payloadHash (S) is the 32-byte hash of the payload (all transactions)
  • generatorRS (S) is the Reed-Solomon address of the generating account
  • nextBlock (S) is the next block ID
  • numberOfTransactions (N) is the number of transactions in the block
  • blockSignature (S) is the 64-byte block signature
  • transactions (A) is an array of transaction IDs or transaction objects (if includeTransactions provided, refer to Get Transaction for details)
  • executedPhasedTransactions (A) is an array of transaction IDs or transaction objects (if includeExecutedPhased provided, refer to Get Transaction for details)
  • version (N) is the block version
  • totalFeeNQT (S) is the total fee (in NQT) of the transactions in the block
  • previousBlock (S) is the previous block ID
  • cumulativeDifficulty (S) is the cumulative difficulty for the next block generation
  • block (S) is the block ID
  • height (N) is the zero-based block height
  • timestamp (N) is the timestamp (in seconds since the genesis block) of the block
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)
Response Example
getBlock - Getting a block
{
 "previousBlockHash": "c0574d7a7b8497373dbead497c2dc7f60fdcfc8c5a9fcb48f7d373acc9bbb099",
 "payloadLength": 1189,
 "totalAmountNQT": "100000000",
 "generationSignature": "c5098d37267bc71134fc8572a87b4af8727a2e5139d60fe8833fab98af22244a",
 "generator": "11693867635361772359",
 "generatorPublicKey": "fbb72a280228af5c8c74c7c754a290e1539f839553c00bc560cac7bfdb324a7c",
 "baseTarget": "1530224444",
 "payloadHash": "633992be640a593ba04e31ca4028deed70bbf47cff333e2a0372a4e2a4aba205",
 "generatorRS": "bened-walet",
 "nextBlock": "5937170741469897491",
 "requestProcessingTime": 175,
 "numberOfTransactions": 6,
 "blockSignature": "ff65a82e385c135cf9bd5be0861e9e5d3d3174fbd993e5b7f57935ec4...",
 "transactions": [
  "15184285173972564233",
  "15200280108574630445",
  "15200507403046301754",
  "15900338016714606285",
  "17881859777840687131",
  "18361738217269620028"
 ],
 "version": 3,
 "totalFeeNQT": "600000000",
 "previousBlock": "4005816059437078464",
 "cumulativeDifficulty": "10229109959119715",
 "block": "8455642159445842600",
 "height": 275730,
 "timestamp": 29797208
}
2.Get Block id
Getting a block by number
Request
Response
Example
Request:
?requestType=getBlockId
&height=0

  • requestType is getBlockId
  • height is the block height
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)
Response:

  • block (S) is the block ID
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)
Response Example
getBlockId - Getting block by number
{
 "block": "2680262203532249785",
 "requestProcessingTime": 1
}
3.Get Blocks
Getting the latest blocks
Request
Response
Example
Request:
?requestType=getBlocks&lastIndex=1

  • requestType is getBlocks
  • timestamp is the earliest block (in seconds since the genesis block) to retrieve (optional)
  • firstIndex is first block to retrieve (optional, default is zero or the last block on the blockchain)
  • lastIndex is the last block to retrieve (optional, default is firstIndex + 99)
  • includeTransactions is true to include transaction details (optional)
  • includeExecutedPhased is true to include approved and executed phased transactions (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)
Response:

  • blocks (A) is an array of blocks retrieved (refer to Get Block for details)
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)
Response Example
getBlocks - Getting latest blocks
{
 "blocks": [
  {
   "previousBlockHash": "f88c75a36317e1795348330cb9a944f33153b517ebdf05d9f3f9a606e997618d",
   "payloadLength": 981,
   "totalAmountNQT": "0",
   "generationSignature": "02f7462b62270c0028c379d838d3a192cf0b782995f3bb1929a5378d26e7e8a9",
   "generator": "2218289317977832095",
   "generatorPublicKey": "98ccf5d5173b13e4c9eab2631372f61ce8ba506db559d73b285073a689872e75",
   "baseTarget": "151761236",
   "payloadHash": "82f8c8ca1f8f2252172ed1e9836d5228432fcb18aecfa7d55a119efcd242321c",
   "generatorRS": "bened-walet",
   "numberOfTransactions": 5,
   "blockSignature": "76a3f7f966256c4985262fb4622190b2b9a19b900f6ce443ab7d581e3176c...",
   "transactions": [
    "10545999940082849455",
    "16751328983055099280",
    "1257496316971695605",
    "2048859884870801838",
    "5105170273384355243"
   ],
   "version": 3,
   "totalFeeNQT": "500000000",
   "previousBlock": "8782326465060769016",
   "block": "7299310714263322546",
   "height": 281683,
   "timestamp": 30416681
  },
  {
   "previousBlockHash": "edc2d65d24883b9b32c46da4eec3792a69a5ff9a9b1e629c4e7e0224432c87c9",
   "payloadLength": 0,
   "totalAmountNQT": "0",
   "generationSignature": "8c4944c7a9ef5700d1b89660fdf83bcbd3dbbfbe191fef005d0f248a573816fe",
   "generator": "15766845356521829337",
   "generatorPublicKey": "11636697faf4ade736cedf6c528bec0142353c4d93fce05cdb818c49e0390422",
   "baseTarget": "303522472",
   "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
   "generatorRS": "bened-walet",
   "nextBlock": "7299310714263322546",
   "numberOfTransactions": 0,
   "blockSignature": "90464d183ed01cb0930ef527e746eaa092d1558697c369cc9246add5f6eec...",
   "transactions": [],
   "version": 3,
   "totalFeeNQT": "0",
   "previousBlock": "11185683789279314669",
   "block": "8782326465060769016",
   "height": 281682,
   "timestamp": 30416671
  }
 ],
 "requestProcessingTime": 2
}
4.Get Transaction
Receiving a transaction
Request
Response
Example
Request:
?requestType=getTransaction&
transaction=15200507403046301754

  • requestType is getTransaction
  • transaction is the transaction ID (optional)
  • fullHash is the full hash of the transaction (optional if transaction ID is provided)
  • includePhasingResult is true to retrieve execution status of each phased transaction (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
  • sender (S) is the account ID of the sender
  • senderRS (S) is the Reed-Solomon address of the sender
  • feeNQT (S) is the fee (in NQT) of the transaction
  • amountNQT (S) is the amount (in NQT) of the transaction
  • transactionIndex (N) is a zero-based index giving the order of the transaction in its block
  • timestamp (N) is the time (in seconds since the genesis block) of the transaction
  • referencedTransactionFullHash (S) is the full hash of a transaction referenced by this one, omitted if no previous transaction is referenced
  • confirmations (N) is the number of transaction confirmations
  • subtype (N) is the transaction subtype (refer to Get Constants for a current list of subtypes)
  • block (S) is the ID of the block containing the transaction
  • blockTimestamp (N) is the timestamp (in seconds since the genesis block) of the block
  • height (N) is the height of the block in the blockchain
  • senderPublicKey (S) is the public key of the sending account for the transaction
  • type (N) is the transaction type (refer to Get Constants for a current list of types)
  • deadline (N) is the deadline (in minutes) for the transaction to be confirmed
  • signature (S) is the digital signature of the transaction
  • recipient (S) is the account number of the recipient, if applicable
  • recipientRS (S) is the Reed-Solomon address of the recipient, if applicable
  • fullHash (S) is the full hash of the signed transaction
  • signatureHash (S) is a SHA-256 hash of the transaction signature
  • approved (B) is a boolean indicating if the transaction is approved (only included when includePhasingResult is true and the transaction is phased)
  • result (S) is a string containing the result of the transaction (only included when includePhasingResult is true and the transaction is phased)
  • executionHeight (N) is the height the transaction was executed (only included when includePhasingResult is true and the transaction is phased)
  • transaction (S) is the transaction ID
  • version (N) is the transaction version number
  • phased (B) is true if the transaction is phased, false otherwise
  • ecBlockId (N) is the economic clustering block ID
  • ecBlockHeight (N) is the economic clustering block height
  • attachment (O) is an object containing any additional data needed for the transaction, if applicable
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Note: The block, blockTimestamp and confirmations fields are omitted for unconfirmed transactions. Double-spending transactions are not retrieved.
Response Example
{
 "senderPublicKey": "57fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143b473beec228f79ff93c",
 "signature": "5f0378b7390ff5a815eadd1354de533eef682f139362b153576e2207320a6...",
 "feeNQT": "100000000",
 "transactionIndex": 2,
 "requestProcessingTime": 2842,
 "type": 0,
 "confirmations": 849,
 "fullHash": "3a304584f20cf3d2cbbdd9698ff9a166427005ab98fbe9ca4ad6253651ee81f1",
 "version": 1,
 "ecBlockId": "17321329645912574173",
 "signatureHash": "b35eae7d2f01639810d37694138aa0a86fbbf8a9bf58c2be4f2a5b8f0f30b3f7",
 "senderRS": "bened-walet",
 "subtype": 0,
 "amountNQT": "100000000",
 "sender": "15323192282528158131",
 "recipientRS": "bened-walet",
 "recipient": "17013046603665206934",
 "ecBlockHeight": 275727,
 "block": "8455642159445842600",
 "blockTimestamp": 29797208,
 "deadline": 60,
 "transaction": "15200507403046301754",
 "timestamp": 29796934,
 "height": 275730
}
5.Send Money
Creating a request for a transaction.
Request
Response
Example
Request:
Refer to Create Transaction Request for common parameters

  • requestType is sendMoney
  • amountNQT is the amount (in NQT) in the transaction
  • recipient is the account ID of the recipient
  • recipientPublicKey is the public key of the receiving account (optional, enhances security of a new account)

  • ?requestType=sendMoney&
  • secretPhrase=IWontTellYou&
  • recipient=bened-walet&
  • amountNQT=100000000&
  • feeNQT=100000000&
  • deadline=60
Response:
Refer to Create Transaction Response.
Response Example
{
 "signatureHash": "b35eae7d2f01639810d37694138aa0a86fbbf8a9bf58c2be4f2a5b8f0f30b3f7",
 "unsignedTransactionBytes": "001046aac6013c0057fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143...",
 "transactionJSON": {
  "senderPublicKey": "57fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143b473beec228f79ff93c",
  "signature": "5f0378b7390ff5a815eadd1354de533eef682f139362b153576e2207320a6...",
  "feeNQT": "100000000",
  "type": 0,
  "fullHash": "3a304584f20cf3d2cbbdd9698ff9a166427005ab98fbe9ca4ad6253651ee81f1",
  "version": 1,
  "ecBlockId": "17321329645912574173",
  "signatureHash": "b35eae7d2f01639810d37694138aa0a86fbbf8a9bf58c2be4f2a5b8f0f30b3f7",
  "senderRS": "bened-walet",
  "subtype": 0,
  "amountNQT": "100000000",
  "sender": "15323192282528158131",
  "recipientRS": "bened-walet",
  "recipient": "17013046603665206934",
  "ecBlockHeight": 275727,
  "deadline": 60,
  "transaction": "15200507403046301754",
  "timestamp": 29796934,
  "height": 2147483647
 },
 "broadcasted": true,
 "requestProcessingTime": 8475,
 "transactionBytes": "001046aac6013c0057fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143...",
 "fullHash": "3a304584f20cf3d2cbbdd9698ff9a166427005ab98fbe9ca4ad6253651ee81f1",
 "transaction": "15200507403046301754"
}
6.Broadcast Transaction
Signing a previously created transaction request.
Request
Response
Example
Request:
Broadcast a transaction to the network. POST only.

?requestType=broadcastTransaction&
transactionBytes=001046aac6013c0057fb6f3a958
e320bb49c4e81b4c2cf28b9f25d086c143...

  • requestType is broadcastTransaction
  • transactionBytes is the bytecode of a signed transaction (optional)
  • transactionJSON is the transaction object (optional if transactionBytes provided)
  • prunableAttachmentJSON is the attachment object embedded in transactionJSON containing a prunable message (required if transactionJSON not provided because transactionBytes never includes prunable data)
Response:
  • requestProcessingTime (N) is the API request processing time (in millisec)
  • fullHash (S) is the full hash of the signed transaction
  • transaction (S) is the transaction ID
Response Example
{
 "requestProcessingTime": 4,
 "fullHash": "3a304584f20cf3d2cbbdd9698ff9a166427005ab98fbe9ca4ad6253651ee81f1",
 "transaction": "15200507403046301754"
}
7.Get Account Id
Get an account ID given a secret passphrase or public key. POST only.
Request
Response
Example
Request:
?requestType=getAccountId&
secretPhrase=IWontTellYou

  • requestType is getAccountId
  • secretPhrase is the secret passphrase of the account (optional)
  • publicKey is the public key of the account (optional if secretPhrase provided)
Response:
  • accountRS (S) is the Reed-Solomon address of the account
  • publicKey (S) is the public key of the account
  • requestProcessingTime (N) is the API request processing time (in millisec)
  • account (S) is the account number
Response Example
{
 "accountRS": "bened-walet",
 "publicKey": "57fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143b473beec228f79ff93c",
 "requestProcessingTime": 2,
 "account": "15323192282528158131"
}
8.Get Balance
Get the balance of an account.
Request
Response
Example
Request:
?requestType=getBalance&
account=bened3leu28gctm6u4gagl

  • requestType is getBalance
  • account is an account ID
  • includeEffectiveBalance is true to include effectiveBalanceNXT and guaranteedBalanceNQT (optional)
  • height is the height to retrieve account balance for, if still available (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
  • unconfirmedBalanceNQT (S) is balanceNQT less unconfirmed outgoing transactions, the balance displayed in the client
  • guaranteedBalanceNQT (S) is the balance (in NQT) of the account with at least 1440 confirmations
  • effectiveBalanceNXT (N) is the balance (in NXT) of the account available for forging: the unleased guaranteedBalance of this account plus the leased guaranteedBalance of all lessors to this account
  • forgedBalanceNQT (S) is the balance (in NQT) that the account has forged
  • balanceNQT (S) is the minimally confirmed basic balance (in NQT) of the account
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)
Response Example
{
    "unconfirmedBalanceNQT": "12",
    "forgedBalanceNQT": "0",
    "balanceNQT": "12",
    "requestProcessingTime": 1
}
9.Get Account Public Key
Get the public key associated with an account ID.
Request
Response
Example
Request:
?requestType=getAccountPublicKey&
account=bened3leu28gctm6u4gagl


  • requestType is getAccountPublicKey
  • account is the account ID
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
  • publicKey (S) is the 32-byte public key associated with the account, returned as a hex string
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)
Response Example
{
 "publicKey": "57fb6f3a958e320bb49c4e81b4c2cf28b9f25d...",
 "requestProcessingTime": 36
}
10.Get Blockchain Status
Get the blockchain status.
Request
Response
Example
Request:
?requestType=getBlockchainStatus

  • requestType is getBlockchainStatus
Response:
  • currentMinRollbackHeight (N) is the current minimum rollback height
  • numberOfBlocks (N) is the number of blocks in the blockchain (height + 1)
  • isTestnet (B) is true if the node is connected to testnet, false otherwise
  • includeExpiredPrunable (B) is the value of the nxt.includeExpiredPrunable property
  • requestProcessingTime (N) is the API request processing time (in millisec)
  • version (S) is the application version
  • maxRollback (N) is the value of the nxt.maxRollback property
  • lastBlock (S) is the last block ID on the blockchain
  • application (S) is application name, typically NRS
  • isScanning (B) is true if the blockchain is being scanned by the application, false otherwise
  • isDownloading (B) is true if a download is in progress, false otherwise; true when a batch of more than 10 blocks at once has been downloaded from a peer, reset to false when an attempt to download more blocks from a peer does not result in any new blocks
  • cumulativeDifficulty (S) is the cumulative difficulty
  • lastBlockchainFeederHeight (N) is the height of the last blockchain of greatest cumulative difficulty obtained from a peer
  • maxPrunableLifetime (N) is the maximum prunable lifetime (in seconds)
  • time (N) is the current timestamp (in seconds since the genesis block)
  • lastBlockchainFeeder (S) is the address or announced address of the peer providing the last blockchain of greatest cumulative difficulty
  • blockchainState (S) Current state of this node's blockchain (UP_TO_DATE or DOWNLOADING)
Response Example
{
    "apiProxy": false,
    "correctInvalidFees": true,
    "ledgerTrimKeep": 30000,
    "maxAPIRecords": 100,
    "blockchainState": "UP_TO_DATE",
    "currentMinRollbackHeight": 121200,
    "numberOfBlocks": 122560,
    "isTestnet": false,
    "includeExpiredPrunable": true,
    "isLightClient": false,
    "services": [
        "API",
        "API_SSL",
        "CORS"
    ],
    "requestProcessingTime": 3,
    "version": "0.0.0.1",
    "maxRollback": 800,
    "lastBlock": "14248468661966364222",
    "application": "BND",
    "isScanning": false,
    "isDownloading": false,
    "cumulativeDifficulty": "1117541424500920",
    "lastBlockchainFeederHeight": 122559,
    "maxPrunableLifetime": 7776000,
    "time": 6297968,
    "lastBlockchainFeeder": "5.182.17.81"
}

BENED API

<?php

function request($action, $data=array()){
	
	$url = 'http://localhost/xsrv';
	
	$data['requestType'] = $action;

	$body_string = http_build_query($data);
	
	if($ch = curl_init()){
		
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0');
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $body_string);
		// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
		curl_setopt($ch, CURLOPT_HEADER, false);
		curl_setopt($ch, CURLOPT_TIMEOUT, 20);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
		
		$err  = curl_errno($ch);
		$result = curl_exec($ch);
		
		curl_close($ch);
		
		
		$res = @json_decode($result, true);

		return $res;				 
	}					
		
	return '';
}








// Wallet generation by passphrase, the phrase must be generated complex and unique.

function getAccountId($secretPhrase){
	
	$data = [];
	
	$data['secretPhrase'] = $secretPhrase;
	
	$res = request('getAccountId', $data);
	return $res;
}
		
// Get node status data.
		
function getBlockchainStatus($data = []){
	$res = request('getBlockchainStatus', $data);
	return $res;
}

// get block data by height ($height) or block number ($block)

function getBlock($height = 0, $block = 0){
	
	$data = [];
	
	if($height > 0) {
		$data['height'] = $height;
	}	
	
	if($block > 0) {
		$data['block'] = $block;
	}
	
	$res = request('getBlock', $data);
	return $res;
}


// get block ID by block height ($height)

function getBlockId($height = 0){
	
	$data = [];
	
	if($height >= 0) {
		$data['height'] = $height;
	}	
	
	$res = request('getBlockId', $data);
	return $res;
}

// get latest blocks with transactions ($includeTransactions = true)

function getBlocks($lastIndex = 0, $includeTransactions = true){
	
	$data = [];
	
	if($lastIndex > 0) {
		$data['lastIndex'] = $lastIndex;
	}	
	
	if($includeTransactions == true) {
		$data['includeTransactions'] = 'true';
	}	
	
	$res = request('getBlocks', $data);
	return $res;
}

// get transaction data by number
function getTransaction($transaction){
	
	$data = [];
	
	if($transaction > 0) {
		$data['transaction'] = $transaction;
	}	
	
	$res = request('getTransaction', $data);
	return $res;
}

// get account balance by account ID
function getBalance($account){
	
	$data = [];

	if($account) {
		$data['account'] = $account;
	}	
	
	$res = request('getBalance', $data);
	return $res;
}




// get PublicKey from account wallet
function getAccountPublicKey($account){
	
	$data = [];

	if($account) {
		$data['account'] = $account;
	}	
	
	$res = request('getAccountPublicKey', $data);
	return $res;
}

// sign a transaction for sending (first we launch SendMoney, then we use the received transactionBytes field)

function broadcastTransaction($transactionBytes){
	
	$data = [];

	if($transactionBytes) {
		$data['transactionBytes'] = $transactionBytes;
	}	
	
	$res = request('broadcastTransaction', $data);
	return $res;
}



function sendMoney($recipient, $publicKey, $amountNQT, $feeNQT){
	
	$data = [];
	$secretPhrase = "***"; // sender wallet password
	
	$data['deadline'] = 60;
	$data['secretPhrase'] = $secretPhrase; 
	$data['publicKey'] = $publicKey; // recipient's publicKey

	if($recipient) {
		$data['recipient'] = $recipient;
	}

	if($amountNQT) {
		$data['amountNQT'] = $amountNQT;
	}
	
	if($feeNQT) {
		$data['feeNQT'] = $feeNQT;
	}	
	
	$data['message'] = 'Test-'.time();
	
	$res = request('sendMoney', $data);
	return $res;
}