> Feedback: If these docs are stale, missing, or confusing, post sanitized feedback to `https://docs.tempo.xyz/api/feedback` with `source: "mcp"`, a short `message`, and any relevant `toolName`, `relatedResource`, or `client`.
# Rust

Tempo distributes a Rust SDK in the form of an [Alloy](https://alloy.rs) crate. Alloy is a popular Rust crate for interacting with EVM-compatible blockchains.

The Tempo Alloy crate can be used to perform common operations with the chain, such as: querying the chain, sending Tempo Transactions, managing tokens & their AMM pools, and more.

::::steps

## Install

To install the Tempo extension, you will need to install [Alloy](https://alloy.rs) and Tempo:

```bash [cargo]
cargo add alloy tokio
cargo add tempo-alloy --git https://github.com/tempoxyz/tempo --tag v1.4.2
```

:::tip
We use [`tokio`](https://tokio.rs) in this example, but you can use any async runtime.
:::

## Configure A Provider

To use the Tempo extension crate, you will need to create a [`Provider`] using the [`TempoNetwork`](https://tempoxyz.github.io/tempo/tempo_alloy/struct.TempoNetwork.html). This will enable the usage of Tempo specific types on the [`Provider`] instance.

For more information about network types, see the Alloy [documentation](https://alloy.rs/guides/interacting-with-multiple-networks#interacting-with-multiple-networks).

```rs [main.rs]
use alloy::providers::ProviderBuilder; // [!code focus]
use tempo_alloy::TempoNetwork; // [!code focus]

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let provider = ProviderBuilder::new_with_network::<TempoNetwork>() // [!code focus]
        .connect(&std::env::var("RPC_URL").expect("No RPC URL set")) // [!code focus]
        .await?; // [!code focus]

    println!("Provider connected successfully"); // [!code focus]
    println!("Chain ID: {provider:?}"); // [!code focus]

    Ok(())
}
```

## Use Actions

Now we are ready to use the provider to interact with the network. We can use the provider to send transactions, read data, and more.

```rs [main.rs]
use alloy::providers::{Provider, ProviderBuilder};
use tempo_alloy::TempoNetwork;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let provider = ProviderBuilder::new_with_network::<TempoNetwork>()
        .connect(&std::env::var("RPC_URL").expect("No RPC URL set"))
        .await?;

    // [!code focus:2]
    println!("{}", provider.get_block_number().await?);
    // @log: 421045
    Ok(())
}
```

See the Alloy [documentation](https://alloy.rs) or the [`Provider`] docs for more examples.

[`Provider`]: https://docs.rs/alloy/latest/alloy/providers/trait.Provider.html

::::
