# Interact With Node
Use you can Assets and Address API methods.
# Assets API
You can get:
- Asset Balance Distribution.
- All Asset Balances for an Address.
- Balance of a Specific Asset.
- Asset Details.
- Non-Fungible Tokens (NFTs) at an Address.
# Asset Balance Distribution
Endpoint: GET /assets/{assetId}/distribution/{height}/limit/{limit}
<?php
// Specify an asset ID.
$assetId = "PASTE AN ASSET ID";
// Specify the maximum number of entries to return.
$limit = 100;
/*
* Specify the network:
* - Mainnet: "https://nodes.wavesnodes.com"
* - Testnet: "https://nodes-testnet.wavesnodes.com"
* - Stagenet: "https://nodes-stagenet.wavesnodes.com"
*/
$nodeUrl = "https://nodes-testnet.wavesnodes.com";
// Get the latest block height.
$heightUrl = $nodeUrl . "/blocks/height";
$heightResponse = file_get_contents($heightUrl);
$height = json_decode($heightResponse, true)['height'];
// Decrement to get the last full block height.
$height -= 1;
// Build the URL for asset distribution.
$url = "$nodeUrl/assets/$assetId/distribution/$height/limit/$limit";
$response = file_get_contents($url);
// Analyze the output.
$data = json_decode($response, true);
// Print the results.
echo "––––––––––––––––––––––––––––––––––––––\n";
echo "Asset Distribution (address: quantity):\n";
foreach ($data['items'] as $address => $amount) {
$balanceInWaves = $amount / 100.0;
printf("%s: %.2f\n", $address, $balanceInWaves);
}
// Check if more pages are available.
if (!empty($data['hasNext']) && $data['hasNext'] === true) {
if (!empty($data['lastItem'])) {
printf("\nMore pages available. Last item: %s\n", $data['lastItem']);
}
}
# All Asset Balances for an Address
Endpoint: GET /assets/balance/{address}
<?php
// Specify an account address.
$address = 'PASTE AN ADDRESS';
/*
* Specify the network:
* - Mainnet: 'https://nodes.wavesnodes.com/'
* - Testnet: 'https://nodes-testnet.wavesnodes.com/'
* - Stagenet: 'https://nodes-stagenet.wavesnodes.com/'
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Build the JSON request.
function getJson(array $opts): ?array {
$ch = curl_init();
curl_setopt_array($ch, $opts);
$resp = curl_exec($ch);
curl_close($ch);
if ($resp === false) return null;
return json_decode($resp, true);
}
// Build the URL.
$balanceUrl = $nodeUrl . '/assets/balance/' . $address;
$balancesResp = getJson([
CURLOPT_URL => $balanceUrl,
CURLOPT_RETURNTRANSFER => true,
]);
$balances = $balancesResp['balances'] ?? [];
// Print the results.
echo "––––––––––––––––––––––––––––––––––––––\n";
echo "All Asset Balances for Address: $address\n";
$decimalsCache = ['WAVES' => 8];
foreach ($balances as $entry) {
$assetIdRaw = $entry['assetId'];
$assetKey = $assetIdRaw === '' ? 'WAVES' : $assetIdRaw;
$rawBalance = $entry['balance'];
if (!isset($decimalsCache[$assetKey])) {
$detailsUrl = $nodeUrl . '/assets/details/' . $assetIdRaw;
$details = getJson([
CURLOPT_URL => $detailsUrl,
CURLOPT_RETURNTRANSFER => true,
]) ?? [];
$decimalsCache[$assetKey] = $details['decimals'] ?? 0;
}
$decimals = $decimalsCache[$assetKey];
$formatted = $rawBalance / (10 ** $decimals);
$balanceStr = number_format($formatted, $decimals, '.', '');
echo "Asset ID: {$assetKey}, Balance: {$balanceStr}\n";
}
# Balance of a Specific Asset
Endpoint: GET /assets/balance/{address}/{assetId}
<?php
// Specify an account address.
$address = 'PASTE AN ADDRESS';
// Specify an asset ID.
$assetId = 'PASTE AN ASSET ID';
/*
* Specify the network:
* - Mainnet: "https://nodes.wavesnodes.com/"
* - Testnet: "https://nodes-testnet.wavesnodes.com/"
* - Stagenet: "https://nodes-stagenet.wavesnodes.com/"
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Perform a GET request and decode JSON response as an array.
function getJson(array $opts): ?array {
$ch = curl_init();
curl_setopt_array($ch, $opts);
$resp = curl_exec($ch);
curl_close($ch);
if ($resp === false) return null;
return json_decode($resp, true);
}
$balanceUrl = "{$nodeUrl}/assets/balance/{$address}/{$assetId}";
$resp = getJson([
CURLOPT_URL => $balanceUrl,
CURLOPT_RETURNTRANSFER => true,
]) ?? [];
$rawBalance = $resp['balance'] ?? 0;
$detailsUrl = "{$nodeUrl}/assets/details/{$assetId}";
$details = getJson([
CURLOPT_URL => $detailsUrl,
CURLOPT_RETURNTRANSFER => true,
]) ?? [];
$decimals = $details['decimals'] ?? 0;
$formatted = $rawBalance / (10 ** $decimals);
// Print the results.
echo "––––––––––––––––––––––––––––––––––––––\n";
printf(
"Asset %s balance for %s: %." . $decimals . "f\n",
$assetId,
$address,
$formatted
);
# Asset Details
Endpoint: GET /assets/details/{assetId}
<?php
// Specify an asset ID.
$assetId = 'PASTE AN ASSET ID';
/*
* Specify the network:
* - Mainnet: "https://nodes.wavesnodes.com/"
* - Testnet: "https://nodes-testnet.wavesnodes.com/"
* - Stagenet: "https://nodes-stagenet.wavesnodes.com/"
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Perform a GET request and decode JSON response as an array.
function getJson(array $opts): ?array {
$ch = curl_init();
curl_setopt_array($ch, $opts);
$resp = curl_exec($ch);
curl_close($ch);
if ($resp === false) return null;
return json_decode($resp, true);
}
$detailsUrl = "{$nodeUrl}/assets/details/{$assetId}";
$details = getJson([
CURLOPT_URL => $detailsUrl,
CURLOPT_RETURNTRANSFER => true,
]) ?? [];
$name = $details['name'] ?? '';
$description = $details['description'] ?? '';
$decimals = isset($details['decimals']) ? (int)$details['decimals'] : 0;
$reissuable = isset($details['reissuable']) ? (bool)$details['reissuable'] : false;
$issuer = $details['issuer'] ?? '';
// Print the results.
echo "––––––––––––––––––––––––––––––––––––––\n";
printf(
"Name: %s\nDescription: %s\nDecimals: %d\nReissuable: %s\nIssuer: %s\n",
$name,
$description,
$decimals,
$reissuable ? 'true' : 'false',
$issuer
);
# Non-Fungible Tokens (NFTs) at an Address
Endpoint: GET /assets/nft/{address}/limit/{limit}
<?php
// Specify an account address.
$address = 'PASTE AN ADDRESS';
// Specify the maximum number of entries to return.
$limit = 100;
/*
* Specify the network:
* - Mainnet: "https://nodes.wavesnodes.com/"
* - Testnet: "https://nodes-testnet.wavesnodes.com/"
* - Stagenet: "https://nodes-stagenet.wavesnodes.com/"
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Build the request URL.
$url = "{$nodeUrl}/assets/nft/{$address}/limit/{$limit}";
// Send GET request and decode response.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$nfts = json_decode($response, true) ?: [];
// Print the results.
echo "––––––––––––––––––––––––––––––––––––––\n";
echo "NFTs at Address: $address\n";
foreach ($nfts as $nft) {
$assetId = $nft['assetId'] ?? '';
$name = $nft['name'] ?? '';
$description = $nft['description'] ?? '';
$quantity = isset($nft['quantity']) ? (int)$nft['quantity'] : 0;
printf(
"ID: %s | Name: %s | Description: %s | Quantity: %d\n",
$assetId,
$name,
$description,
$quantity
);
}
# Addresses API
You can get:
- All Addresses in the Node Wallet.
- A Range of Addresses.
- WAVES Balance of an Address.
- WAVES Balance with Confirmations.
- Detailed Balance Information.
- Balances for Multiple Addresses.
- Account Data Entries by Address.
- Data Entry by Key.
- Script Information of an Account.
# All Addresses in the Node Wallet
Endpoint: GET /addresses
<?php
/*
* Specify the network:
* - Mainnet: "https://nodes.wavesnodes.com/"
* - Testnet: "https://nodes-testnet.wavesnodes.com/"
* - Stagenet: "https://nodes-stagenet.wavesnodes.com/"
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Build the request URL.
$url = $nodeUrl . '/addresses';
// Send the GET request and decode the response.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$addresses = json_decode($response, true) ?: [];
// Print the results.
echo "––––––––––––––––––––––––––––––––––––––\n";
echo "Node Wallet Addresses:\n";
foreach ($addresses as $addr) {
echo $addr . "\n";
}
# Range of Addresses
Endpoint: GET /addresses/seq/{from}/{to}
<?php
// Wallet index range.
$from = 0;
$to = 4;
/*
* Specify the network:
* - Mainnet: "https://nodes.wavesnodes.com/"
* - Testnet: "https://nodes-testnet.wavesnodes.com/"
* - Stagenet: "https://nodes-stagenet.wavesnodes.com/"
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Build the request URL.
$url = sprintf('%s/addresses/seq/%d/%d', $nodeUrl, $from, $to);
// Send the GET request and decode the response.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$addresses = json_decode($response, true) ?: [];
// Print the results.
printf("Addresses %d to %d:\n", $from, $to);
foreach ($addresses as $addr) {
echo $addr . "\n";
}
# WAVES Balance of an Address
Endpoint: GET /addresses/balance/{address}
<?php
// Specify an account address.
$address = 'PASTE AN ADDRESS';
/*
* Specify the network:
* - Mainnet: 'https://nodes.wavesnodes.com/'
* - Testnet: 'https://nodes-testnet.wavesnodes.com/'
* - Stagenet: 'https://nodes-stagenet.wavesnodes.com/'
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Build the request URL.
$url = $nodeUrl . '/addresses/balance/' . $address;
// Send the GET request and decode the JSON response.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true) ?: [];
$raw = isset($data['balance']) ? (int)$data['balance'] : 0;
// Print the results.
printf("Balance at %s: %.8f WAVES\n", $address, $raw / 1e8);
# WAVES Balance with Confirmations
Endpoint: GET /addresses/balance/{address}/{confirmations}
<?php
// Specify an account address.
$address = 'PASTE AN ADDRESS';
// Enter the number of confirmations.
$confirmations = 2;
/*
* Specify the network:
* - Mainnet: 'https://nodes.wavesnodes.com/'
* - Testnet: 'https://nodes-testnet.wavesnodes.com/'
* - Stagenet: 'https://nodes-stagenet.wavesnodes.com/'
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Build the request URL.
$url = sprintf('%s/addresses/balance/%s/%d', $nodeUrl, $address, $confirmations);
// Send the GET request and decode the JSON response.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true) ?: [];
$raw = isset($data['balance']) ? (int)$data['balance'] : 0;
// Print the results.
printf(
"Balance at %s (>= %d confirmations): %.8f WAVES\n",
$address,
$confirmations,
$raw / 1e8
);
# Detailed Balance Information
Endpoint: GET /addresses/balance/details/{address}
NOTE: The method shows the available, regular, generating, and effective account balances.
<?php
// Specify an account address.
$address = 'PASTE AN ADDRESS';
/*
* Specify the network:
* - Mainnet: 'https://nodes.wavesnodes.com/'
* - Testnet: 'https://nodes-testnet.wavesnodes.com/'
* - Stagenet: 'https://nodes-stagenet.wavesnodes.com/'
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Build the request URL.
$url = $nodeUrl . '/addresses/balance/details/' . $address;
// Send the GET request and decode the JSON response.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$info = json_decode($response, true) ?: [];
// Print the results.
printf("Regular: %.8f WAVES\n", (isset($info['regular']) ? $info['regular'] : 0) / 1e8);
printf("Available: %.8f WAVES\n", (isset($info['available']) ? $info['available'] : 0) / 1e8);
printf("Generating:%.8f WAVES\n", (isset($info['generating'])? $info['generating']: 0) / 1e8);
printf("Effective: %.8f WAVES\n", (isset($info['effective']) ? $info['effective'] : 0) / 1e8);
# Balances for Multiple Addresses
Endpoint: POST /addresses/balance
<?php
// Specify account addresses.
$addresses = [
'PASTE 1ST ADDRESS',
'PASTE 2ND ADDRESS',
// ...
];
/*
* Specify the network:
* - Mainnet: 'https://nodes.wavesnodes.com/addresses/balance'
* - Testnet: 'https://nodes-testnet.wavesnodes.com/addresses/balance'
* - Stagenet: 'https://nodes-stagenet.wavesnodes.com/addresses/balance'
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com/addresses/balance';
// Prepare the POST body.
$body = json_encode(['addresses' => $addresses]);
// Send the POST request and decode the JSON response.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $nodeUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
$results = json_decode($response, true) ?: [];
// Print the results.
foreach ($addresses as $i => $address) {
$balance = isset($results[$i]['balance']) ? $results[$i]['balance'] / 1e8 : 0;
printf("%s: %.8f WAVES\n", $address, $balance);
}
# Account Data Entries by Address
Endpoint: GET /addresses/data/{address}
<?php
// Specify an account address.
$address = 'PASTE AN ADDRESS';
/*
* Specify the network:
* - Mainnet: 'https://nodes.wavesnodes.com'
* - Testnet: 'https://nodes-testnet.wavesnodes.com'
* - Stagenet: 'https://nodes-stagenet.wavesnodes.com'
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Build the request URL.
$url = $nodeUrl . '/addresses/data/' . $address;
// Send the GET request and decode the JSON response.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$entries = json_decode($response, true) ?: [];
// Print the results.
foreach ($entries as $entry) {
printf("%s (%s): %s\n", $entry['key'], $entry['type'], $entry['value']);
}
# Data Entry by Key
Endpoint: GET /addresses/data/{address}/{key}
<?php
// Specify an account address.
$address = 'PASTE AN ADDRESS';
// Specify an account key.
$key = 'PASTE AN ACCOUNT KEY';
/*
* Specify the network:
* - Mainnet: 'https://nodes.wavesnodes.com'
* - Testnet: 'https://nodes-testnet.wavesnodes.com'
* - Stagenet: 'https://nodes-stagenet.wavesnodes.com'
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Build the request URL.
$url = $nodeUrl . '/addresses/data/' . $address . '/' . $key;
// Send the GET request and decode the JSON response.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$entry = json_decode($response, true) ?: [];
// Print the result.
printf("%s (%s): %s\n", $entry['key'], $entry['type'], $entry['value']);
# Script Information of an Account
Endpoint: GET /addresses/scriptInfo/{address}
<?php
// Specify an account address.
$address = 'PASTE AN ADDRESS';
/*
* Specify the network:
* - Mainnet: 'https://nodes.wavesnodes.com'
* - Testnet: 'https://nodes-testnet.wavesnodes.com'
* - Stagenet: 'https://nodes-stagenet.wavesnodes.com'
*/
$nodeUrl = 'https://nodes-testnet.wavesnodes.com';
// Build the request URL.
$url = $nodeUrl . '/addresses/scriptInfo/' . $address;
// Send the GET request and decode the JSON response.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$info = json_decode($response, true) ?: [];
// Print the results.
$hasScript = isset($info['script']) && $info['script'] !== null;
printf("Has Script: %s\n", $hasScript ? 'true' : 'false');
if ($hasScript) {
printf("Complexity: %d\nExtra Fee: %d\n", $info['complexity'], $info['extraFee']);
}