pub struct RelayClient { /* private fields */ }

Implementations§

Examples found in repository?
examples/stream_tx.rs (line 31)
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
fn main()
{
    let pk_str = get_env("PK");
    let private_key_bytes: &[u8] = pk_str.as_bytes();

    let sk = SecretKey::from_slice(&decode(private_key_bytes).unwrap()).unwrap();

    let pk = SecretKeyRef::new(&sk);

    let address = pk.address();

    let mut client = RelayClient::new(address, &pk).unwrap();

    loop
    {
        let transaction = client.read_tx();
        match transaction
        {
            Some(tx) =>
            {
                println!("Chain ID: {}", tx.chain_id());
                println!("Nonce: {}", tx.nonce());
                println!("Value: {}", tx.value());
                println!("To: {}", tx.tx_to());
                println!("From: {}", tx.tx_from());
                println!("Input: {:?}", tx.input());
                println!("Gas Limit: {}", tx.gas_limit());
                println!("Gas Price: {:?}", tx.gas());
                println!("TX Type: {:?}", tx.tx_type());
            }
            None =>
            {
                println!("Could not connect to Relay. Are you registered?");
                exit(1);
            }
        }
    }
}
More examples
Hide additional examples
examples/send_tx.rs (line 45)
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
async fn main()
{
    // New HTTP provider. The provider is used to get information needed
    // to send a valid TX when sending via the Relay.
    let provider = Http::new(AVAX_API_URL).unwrap();

    // New Web3 instance using the HTTP provider
    let web3 = Web3::new(provider);

    let pk_str = get_env("PK");
    let private_key_bytes: &[u8] = pk_str.as_bytes();

    let sk = SecretKey::from_slice(&decode(private_key_bytes).unwrap()).unwrap();

    let pk = SecretKeyRef::new(&sk);

    let address = pk.address();


    let mut client = RelayClient::new(address, &pk).unwrap();

    let tx = TransactionParameters { value: 0.into(),
                                     nonce: None,
                                     to: Some(address),
                                     chain_id: 43114.into(), // Cam said this may fix it, still nothing.
                                     ..Default::default() };

    let signed_tx = match web3.accounts().sign_transaction(tx, &sk).await
    {
        Ok(signed_tx) => signed_tx,
        Err(e) =>
        {
            println!("Error signing transaction: {:?}", e);
            exit(1);
        }
    };

    println!("Signed tx hash: {:x?}", signed_tx.transaction_hash);

    // this is not working. TX sends successfully, however it doesn't
    // get to the nodes. Does not appear on snowtrace.
    match client.send_tx(signed_tx)
    {
        Ok(_) => println!("Sent transaction successfully."),
        Err(e) =>
        {
            println!("Error sending transaction: {:?}", e);
            exit(1);
        }
    };
}
Examples found in repository?
examples/stream_tx.rs (line 35)
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
fn main()
{
    let pk_str = get_env("PK");
    let private_key_bytes: &[u8] = pk_str.as_bytes();

    let sk = SecretKey::from_slice(&decode(private_key_bytes).unwrap()).unwrap();

    let pk = SecretKeyRef::new(&sk);

    let address = pk.address();

    let mut client = RelayClient::new(address, &pk).unwrap();

    loop
    {
        let transaction = client.read_tx();
        match transaction
        {
            Some(tx) =>
            {
                println!("Chain ID: {}", tx.chain_id());
                println!("Nonce: {}", tx.nonce());
                println!("Value: {}", tx.value());
                println!("To: {}", tx.tx_to());
                println!("From: {}", tx.tx_from());
                println!("Input: {:?}", tx.input());
                println!("Gas Limit: {}", tx.gas_limit());
                println!("Gas Price: {:?}", tx.gas());
                println!("TX Type: {:?}", tx.tx_type());
            }
            None =>
            {
                println!("Could not connect to Relay. Are you registered?");
                exit(1);
            }
        }
    }
}
Examples found in repository?
examples/send_tx.rs (line 67)
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
async fn main()
{
    // New HTTP provider. The provider is used to get information needed
    // to send a valid TX when sending via the Relay.
    let provider = Http::new(AVAX_API_URL).unwrap();

    // New Web3 instance using the HTTP provider
    let web3 = Web3::new(provider);

    let pk_str = get_env("PK");
    let private_key_bytes: &[u8] = pk_str.as_bytes();

    let sk = SecretKey::from_slice(&decode(private_key_bytes).unwrap()).unwrap();

    let pk = SecretKeyRef::new(&sk);

    let address = pk.address();


    let mut client = RelayClient::new(address, &pk).unwrap();

    let tx = TransactionParameters { value: 0.into(),
                                     nonce: None,
                                     to: Some(address),
                                     chain_id: 43114.into(), // Cam said this may fix it, still nothing.
                                     ..Default::default() };

    let signed_tx = match web3.accounts().sign_transaction(tx, &sk).await
    {
        Ok(signed_tx) => signed_tx,
        Err(e) =>
        {
            println!("Error signing transaction: {:?}", e);
            exit(1);
        }
    };

    println!("Signed tx hash: {:x?}", signed_tx.transaction_hash);

    // this is not working. TX sends successfully, however it doesn't
    // get to the nodes. Does not appear on snowtrace.
    match client.send_tx(signed_tx)
    {
        Ok(_) => println!("Sent transaction successfully."),
        Err(e) =>
        {
            println!("Error sending transaction: {:?}", e);
            exit(1);
        }
    };
}

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more