AptosAptos Network's breakthrough technology and seamless user experience are now available on QuickNode.

Start building today!     

Contents

logSubscribe RPC Method

Parameters:

  1. filters - filter criteria for the logs to receive results by account type; currently supported

    "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".

  2. Object - (optional) Configuration object containing the following optional fields:

    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:

  1. Result - The result will be an RpcResponse JSON object with id equal to:

    number - Subscription id (needed to unsubscribe)

Notification Format:

    Result - The notification will be an RpcResponse JSON object with value equal to
  1. 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"
  );
})();
Ready to get started? Create a free account