<!-- tempo-docs-context -->
> Source: [/docs/sdk/rust](https://tempo.xyz/developers/docs/sdk/rust.md)
> Section: [Get Started](https://tempo.xyz/developers/get-started.md). Choose a starting point, send a test payment, get testnet funds, connect a coding agent, and find the SDKs and CLI.
> [Documentation index](https://tempo.xyz/developers/llms.txt) · [Docs skill](https://tempo.xyz/developers/SKILL.md)

> Tempo MCP: Use `search`, `find_pages`, `read_page`, and `code` at `https://mcp.tempo.xyz` for Tempo and related documentation.
> If an indexed page is missing or reflects an older site, read this site’s [documentation index](https://tempo.xyz/developers/llms.txt) and Markdown pages directly.

# Tempo Rust SDK: installing and using it

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 and interacting with the stablecoin exchange, and more.

::::steps
## Install the Rust SDK

Use Rust 1.95 or later for `tempo-alloy` 1.10.1. Install [Alloy](https://alloy.rs), the async runtime, and the Tempo extension:

```bash [cargo]
cargo add alloy@2.1.1
cargo add tokio --features macros,rt-multi-thread
cargo add tempo-alloy --git https://github.com/tempoxyz/tempo --tag tempo-alloy@1.10.1
```

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

## Configure a Rust 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.

Set `RPC_URL=https://rpc.moderato.tempo.xyz` to use Moderato testnet.

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::{Provider, 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.get_chain_id().await?); // [!code focus]

    Ok(())
}
```

## Use Tempo actions in Rust

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
::::
