AptosAptos Network's breakthrough technology and seamless user experience are now available on QuickNode.
Start building today!
Parameters:
"all" - subscribe to all transactions except for simple vote transactions
"allWithVotes" - subscribe to all transactions including simple vote transactions
"mentions": - subscribe to all transactions that mention the provided Pubkey (as base-58 encoded string)
encoding - encoding for Account data, either "base58" (slow), "base64", "base64+zstd", or "jsonParsed".
Commitment - (optional) All fields are strings.
Finalized - the node will query the most recent block confirmed by supermajority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.
Confirmed - the node will query the most recent block that has been voted on by supermajority of the cluster.
Processed - the node will query its most recent block. Note that the block may not be complete.
Returns:
number - Subscription id (needed to unsubscribe)
Notification Format:
signature - The notification will be an RpcResponse JSON object with value equal to:
err - Error if transaction failed, null if transaction succeeded
logs - Array of log messages the transaction instructions output during execution, null if simulation failed before the transaction was able to execute (for example due to an invalid blockhash or signature verification failure)
Code Examples:
const web3 = require("@solana/web3.js"); (async () => { const publicKey = new web3.PublicKey( "E645TckHQnDcavVv92Etc6xSWQaq8zzPtPRGBheviRAk" ); const solanaConnection = new web3.Connection("http://sample-endpoint-name.network.quiknode.pro/token-goes-here/", { wsEndpoint: "wss://sample-endpoint-name.network.quiknode.pro/token-goes-here/", }); solanaConnection.onLogs( publicKey, (logs, context) => console.log("Updated account info: ", logs), "confirmed" ); })();
wscat -c wss://sample-endpoint-name.network.quiknode.pro/token-goes-here/ \ # wait for connection {"id":1,"jsonrpc":"2.0", "method": "logsSubscribe", "params": [ "all" ]}
import solana import asyncio from asyncstdlib import enumerate from solana.rpc.websocket_api import connect async def main(): async with connect("wss://sample-endpoint-name.network.quiknode.pro/token-goes-here/") as websocket: await websocket.log_subscribe() first_resp = await websocket.recv() subscription_id = first_resp.result async for idx, msg in enumerate(websocket): print(msg) asyncio.run(main())