pub struct Client<M: Middleware> {
pub eas: EAS<M>,
pub schema_registry: SchemaRegistry<M>,
}
Fields§
§eas: EAS<M>
§schema_registry: SchemaRegistry<M>
Implementations§
Source§impl<M: Middleware + 'static> Client<M>
impl<M: Middleware + 'static> Client<M>
Source§impl Client<SignerMiddleware<Provider<Http>, Wallet<SigningKey>>>
impl Client<SignerMiddleware<Provider<Http>, Wallet<SigningKey>>>
Sourcepub async fn new<T: Into<Address>>(
endpoint: &str,
eas_contract_address: T,
schema_contract_address: Option<T>,
signing_key: SigningKey,
) -> Result<Self, Box<dyn Error>>
pub async fn new<T: Into<Address>>( endpoint: &str, eas_contract_address: T, schema_contract_address: Option<T>, signing_key: SigningKey, ) -> Result<Self, Box<dyn Error>>
Examples found in repository?
examples/events.rs (line 17)
13async fn main() -> Result<(), Box<dyn Error>> {
14 let singing_key = &hex::decode(SEPOLIA_PRIVATE_KEY_HEX)?;
15 let signing_key = SigningKey::from_slice(singing_key)?;
16 let contract_address = H160::from_str(SEPOLIA_CONTRACT_ADDRESS)?;
17 let client = client::Client::new(SEPOLIA_ENDPOINT, contract_address, None, signing_key).await?;
18
19 // Filter for the events starting with the block ID 5553102
20 let filter = client.eas.attested_event(5553102, None, None);
21
22 // Get the query for the filter
23 // This will return the logs that match the filter all at once
24 let query = filter.query().await?;
25 println!("Query: {:?}", query);
26
27 // Get the stream for the filter
28 let mut stream = filter.stream().await.expect("Failed to get stream");
29
30 // This will print the logs as they come in
31 while let Some(Ok(approval)) = stream.next().await {
32 println!("Approval: {:?}", approval);
33 }
34
35 Ok(())
36}
More examples
examples/schema.rs (line 19)
15async fn main() -> Result<(), Box<dyn Error>> {
16 let singing_key = &hex::decode(SEPOLIA_PRIVATE_KEY_HEX)?;
17 let signing_key = SigningKey::from_slice(singing_key)?;
18 let contract_address = H160::from_str(SEPOLIA_CONTRACT_ADDRESS)?;
19 let client = client::Client::new(SEPOLIA_ENDPOINT, contract_address, None, signing_key).await?;
20
21 let schema = schema::SchemaBuilder::new()
22 .add("id", schema::Type::Address)
23 .add("voter_id", schema::Type::Address)
24 .add("vote_option", schema::Type::Int(32))
25 .build();
26
27 let tx = client.schema_registry.register(schema, None, true).await?;
28 let registered_schema = tx.await?;
29
30 println!("Schema ID: {:?}", registered_schema.schema_uid);
31
32 let naming_schema =
33 H256::from_str("0x44d562ac1d7cd77e232978687fea027ace48f719cf1d58c7888e509663bb87fc")?;
34
35 let data = &[
36 Token::FixedBytes(registered_schema.schema_uid.as_bytes().into()),
37 Token::String("enter schema name here".to_string()),
38 ];
39
40 let attestation_data = AttestationDataBuilder::new()
41 .revocable(true)
42 .data(data)
43 .build();
44
45 let attested = client.eas.attest(&naming_schema, attestation_data).await?;
46 let attested = attested.await?;
47
48 println!("Attestation ID: {:?}", attested);
49
50 Ok(())
51}
examples/attestation.rs (line 19)
15async fn main() -> Result<(), Box<dyn Error>> {
16 let singing_key = &hex::decode(SEPOLIA_PRIVATE_KEY_HEX)?;
17 let signing_key = SigningKey::from_slice(singing_key)?;
18 let contract_address = H160::from_str(SEPOLIA_CONTRACT_ADDRESS)?;
19 let client = client::Client::new(SEPOLIA_ENDPOINT, contract_address, None, signing_key).await?;
20
21 let schema_id =
22 H256::from_str("0x0cf8b15034904dc56810da6237d220c345693077c4d42c53c45263649ed3b585")?;
23
24 let attestation_request = AttestationDataBuilder::new()
25 .revocable(true)
26 .data(&[
27 Token::Address(H160::from_low_u64_be(0x1234567890abcdef)),
28 Token::Address(H160::from_low_u64_be(0x1234567890abcdef)),
29 Token::Int(11.into()),
30 ])
31 .build();
32
33 // attest sends a transaction and returns a PendingTx that can be awaited
34 let tx = client.eas.attest(&schema_id, attestation_request).await?;
35 let attested = tx.await?;
36
37 println!("Attestation ID: {:?}", attested);
38
39 // timestamp send a transaction and returns a PendingTx that can be awaited
40 let tx = client.eas.timestamp(attested.uid).await?;
41 let timestamped = tx.await?;
42
43 println!("Timestamped: {:?}", timestamped);
44
45 // revoke send a transaction and returns a PendingTx that can be awaited
46 let revoked = client
47 .eas
48 .revoke(attested.schema, attested.uid, U256::default())
49 .await?;
50
51 let revoked = revoked.await?;
52
53 println!("Revoked: {:?}", revoked);
54
55 Ok(())
56}
Auto Trait Implementations§
impl<M> Freeze for Client<M>
impl<M> RefUnwindSafe for Client<M>where
M: RefUnwindSafe,
impl<M> Send for Client<M>
impl<M> Sync for Client<M>
impl<M> Unpin for Client<M>where
M: Unpin,
impl<M> UnwindSafe for Client<M>where
M: RefUnwindSafe + UnwindSafe,
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.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> 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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.