subscribeAddresses - Zcash
Example code for the subscribeAddresses WebSocket method. Complete guide on how to use the subscribeAddresses WebSocket method in the GetBlock Web3 documentation.
Subscribes to activity on a set of transparent addresses. When a transaction touches any subscribed address, the server pushes the address and the transaction. This is the basis of payment detection: a deposit is delivered the moment it reaches the mempool.
Parameters
addresses
array
Yes
Transparent Zcash addresses to watch (t1, t3)
newBlockTxs
boolean
No
When true, also push the subscribed addresses' transactions contained in each new block
Message
wscat -c wss://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>
# then send:
{
"id": "addr",
"method": "subscribeAddresses",
"params": {
"addresses": [
"t1KfwsnwJeNRVjQGBDZhwKskpQbih2qx5Ua"
],
"newBlockTxs": true
}
}Response
Notifications
While subscribed, the server pushes the address and the full normalized transaction. The message below was captured live; vin and vout are truncated to one entry each:
A transaction is pushed as soon as it reaches the mempool, carrying confirmations: 0. Confirmation is not delivered as a guaranteed per-transaction follow-up, so do not wait for one to settle a payment: subscribe to subscribeNewBlock as well and re-read the transaction on each block.
Response Fields
subscribed
boolean
Confirms the subscription is active
address
string
Address that received activity (in notifications)
tx
object
The transaction touching the address (in notifications)
confirmationETABlocks
integer
Estimated blocks until confirmation, on unconfirmed transactions
confirmationETASeconds
integer
Estimated seconds until confirmation, on unconfirmed transactions
Use Cases
Payment Detection: Get notified the instant a transparent deposit reaches the mempool
Wallet UX: Update balances on incoming transactions without polling
Confirmation Tracking: Pair with subscribeNewBlock to re-read depth as blocks arrive
Monitoring: Watch hot wallets in real time
Error Handling
error
Invalid address
One of the addresses is invalid or not transparent
403 / RBAC: access denied
Access denied
The GetBlock access token is missing or incorrect
Last updated
Was this helpful?