enter image description here
I want to implement the watchRaydiumV4Initialize2Logs
method, so I need to find something similar to connection.onLogs in Rust, but the RpcClient struct in solana-client does not implement a method similar to this.
So I want to find such an implementation
You need to call logssubscribe
using solana_ws
:
There is an example on GitHub:
/// Subscribe to transaction log events.
///
/// Receives messages of type [`RpcLogsResponse`] when a transaction is committed.
///
/// # RPC Reference
///
/// This method corresponds directly to the [`logsSubscribe`] RPC method.
///
/// [`logsSubscribe`]: https://docs.solana.com/api/websocket#logssubscribe
pub async fn logs_subscribe<F>(
&self,
filter: RpcTransactionLogsFilter,
config: RpcTransactionLogsConfig,
cb: F,
) -> SubscriptionId
where
F: Fn(WithContext<RpcLogsResponse>) + Send + 'static,
{
self.ws
.add_listener("logsSubscribe", Some(json!([filter, config])), cb)
.await
}