# logsSubscribe
Solana API method to subscribe to transaction logging.
# Solana.py
To use the Solana API subscriptions with the solana.py
library, install the asyncstdlib
package with:
pip install asyncstdlib
# cURL
To use the Solana API subscriptions with cURL, use the code example as a message body in a WebSocket request in Postman.
Parameters:
filter: <string>|<object>
— the 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: [ <string> ] }
— subscribe to all transactions that mention the provided public key, as a base58 encoded string.
(optional) <object>
— the configuration object containing the following optional fields:(optional) commitment: <string>
— the commitment.
Returns:
<integer>
— the subscription ID (needed to unsubscribe).
Example:
- Solana web3.js
- Solana.py
- cURL
import { Connection } from "@solana/web3.js";
const web3 = new Connection("CHAINSTACK_HTTPS_URL", {
wsEndpoint: "CHAINSTACK_WSS_URL",
});
(async () => {
const publicKey = new PublicKey(
"5sQ5AuSxmX2avcS99p8ECcvQAAKV3pKL5s6AoAccwuww"
);
web3.onLogs(
publicKey,
(logs) => console.log("Updated account info: ", logs),
"confirmed"
);
})();