pub struct EVMStream { /* private fields */ }Expand description
EVM WebSocket streaming client for HyperEVM
Stream EVM events via WebSocket on the /nanoreth namespace.
§Example
use hyperliquid_sdk::EVMStream;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut stream = EVMStream::new(Some("https://your-endpoint.quiknode.pro/TOKEN".to_string()));
// Subscribe to new block headers
stream.new_heads(|header| {
println!("New block: {:?}", header);
});
// Subscribe to contract logs
stream.logs(
Some(serde_json::json!({"address": "0x..."})),
|log| println!("Log: {:?}", log),
);
stream.start()?;
Ok(())
}Implementations§
Source§impl EVMStream
impl EVMStream
Sourcepub fn configure(self, config: EVMStreamConfig) -> Self
pub fn configure(self, config: EVMStreamConfig) -> Self
Configure stream options
Sourcepub fn on_state_change<F>(self, f: F) -> Self
pub fn on_state_change<F>(self, f: F) -> Self
Set state change callback
Sourcepub fn state(&self) -> EVMConnectionState
pub fn state(&self) -> EVMConnectionState
Get current connection state
Sourcepub fn new_heads<F>(&mut self, callback: F) -> &mut Self
pub fn new_heads<F>(&mut self, callback: F) -> &mut Self
Subscribe to new block headers
Fires a notification each time a new header is appended to the chain, including during chain reorganizations.
Sourcepub fn logs<F>(&mut self, filter: Option<Value>, callback: F) -> &mut Self
pub fn logs<F>(&mut self, filter: Option<Value>, callback: F) -> &mut Self
Subscribe to contract event logs
Returns logs that are included in new imported blocks and match the given filter criteria.
§Arguments
filter- Filter parameters with optionaladdressandtopicscallback- Function called with each matching log
Sourcepub fn new_pending_transactions<F>(&mut self, callback: F) -> &mut Self
pub fn new_pending_transactions<F>(&mut self, callback: F) -> &mut Self
Subscribe to pending transaction hashes
Returns the hash for all transactions that are added to the pending state.
Sourcepub fn subscriptions(&self) -> Vec<String>
pub fn subscriptions(&self) -> Vec<String>
Get list of active subscription IDs
Auto Trait Implementations§
impl Freeze for EVMStream
impl !RefUnwindSafe for EVMStream
impl Send for EVMStream
impl Sync for EVMStream
impl Unpin for EVMStream
impl UnsafeUnpin for EVMStream
impl !UnwindSafe for EVMStream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request