This module provides functions for creating URLs for Blockstream's block explorer.
This module does NOT provide implementations of HTTP requests which fetch data from these URLs.
- Source:
Methods
(static) blockExplorerAPIURL(path, network) → {string}
Returns the block explorer API URL for the given path and network.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | the API path |
network |
module:networks.NETWORKS | bitcoin network |
- Source:
Returns:
the full block explorer url
- Type
- string
Example
import {MAINNET, TESTNET, blockExplorerAPIURL} from "unchained-bitcoin";
const path = "/tx/1814a10fb22e9551a17a94a1e68971e19b4f59eaf1689e0af85b97929b3b9ae0";
console.log(blockExplorerAPIURL(path, MAINNET)); // https://blockstream.info/api/tx/1814a10fb22e9551a17a94a1e68971e19b4f59eaf1689e0af85b97929b3b9ae0
console.log(blockExplorerAPIURL(path, TESTNET)); // https://blockstream.info/testnet/api/tx/1814a10fb22e9551a17a94a1e68971e19b4f59eaf1689e0af85b97929b3b9ae0
(static) blockExplorerAddressURL(address, network) → {string}
Return the block explorer URL for the given address and network.
Parameters:
Name | Type | Description |
---|---|---|
address |
string | the address |
network |
module:networks.NETWORKS | bitcoin network |
- Source:
Returns:
full URL for address lookup
- Type
- string
Example
import {MAINNET, TESTNET, blockExplorerAddressURL} from "unchained-bitcoin";
const address = "39YqNoLULDpbjmeCTdGJ42DQhrQLzRcMdX";
console.log(blockExplorerAddressURL(address, MAINNET)); // https://blockstream.info/address/39YqNoLULDpbjmeCTdGJ42DQhrQLzRcMdX
console.log(blockExplorerAddressURL(address, TESTNET)); // https://blockstream.info/testnet/address/39YqNoLULDpbjmeCTdGJ42DQhrQLzRcMdX
(static) blockExplorerTransactionURL(txid, network) → {string}
Return the block explorer URL for the given transaction ID and network.
Parameters:
Name | Type | Description |
---|---|---|
txid |
string | the transaction id |
network |
module:networks.NETWORKS | bitcoin network |
- Source:
Returns:
the full transaction URL
- Type
- string
Example
import {MAINNET, TESTNET, blockExplorerTransactionURL} from "unchained-bitcoin";
const txid = "1814a10fb22e9551a17a94a1e68971e19b4f59eaf1689e0af85b97929b3b9ae0";
console.log(blockExplorerTransactionURL(txid, MAINNET)); // https://blockstream.info/tx/1814a10fb22e9551a17a94a1e68971e19b4f59eaf1689e0af85b97929b3b9ae0
console.log(blockExplorerTransactionURL(txid, TESTNET)); // https://blockstream.info/testnet/tx/1814a10fb22e9551a17a94a1e68971e19b4f59eaf1689e0af85b97929b3b9ae0
(static) blockExplorerURL(path, network) → {string}
Returns the block explorer URL for the given path and network.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | the explorer path |
network |
module:networks.NETWORKS | bitcoin network |
- Source:
Returns:
the block explorer url
- Type
- string
Example
import {MAINNET, TESTNET, blockExplorerURL} from "unchained-bitcoin";
const path = "/block/00000000000000000011341d69792271766e4683e29b3ea169eacc59bde10a57";
console.log(blockExplorerURL(path, MAINNET)) // https://blockstream.info/block/00000000000000000011341d69792271766e4683e29b3ea169eacc59bde10a57
console.log(blockExplorerURL(path, TESTNET)) // https://blockstream.info/block/testnet/00000000000000000011341d69792271766e4683e29b3ea169eacc59bde10a57