This guide demonstrates how to make payments on the POD Network using the Pod Rust SDK. We’ll cover the entire process, from checking balances to sending transactions and monitoring their status.
For sending and receiving payments with an ethereum-compatible wallet, see Getting Started.
Prerequisites
Before starting, ensure you have:
An account with funds on the pod devnet network, or use the .
pod Rust SDK installed.
Making a Payment
The payment can be initialized as follows:
use eyre::Result;
use pod_sdk::{PrivateKeySigner, TransactionBuilder, PodProviderBuilder};
use alloy_primitives::{Address, U256};
use alloy_signer::k256::ecdsa::SigningKey;
use alloy_network::EthereumWallet;
use alloy::transports::http::Http;
use pod_core::time::SystemClock;
#[tokio::main]
async fn main() -> Result<()> {
let rpc_url = "http://127.0.0.1:8545";
let private_key = "your-private-key-hex";
let recipient: Address = "recipient-address".parse()?;
let value = U256::from(1000);
let signer = PrivateKeySigner::from_signing_key(SigningKey::from_slice(&hex::decode(private_key)?)?);
let wallet = EthereumWallet::new(signer);
let provider = PodProviderBuilder::new()
.with_recommended_fillers()
.wallet(wallet)
.on_http(Http::new(rpc_url)?)
.await?;
let tx = TransactionBuilder::default()
.with_to(recipient)
.with_value(value)
.build();
let pending_tx = provider.send_transaction(tx).await?;
println!("Sent transaction: {:?}", pending_tx.tx_hash());
let receipt = pending_tx.await?;
println!("Confirmed transaction: {:?}", receipt);
let now = SystemClock.now().as_seconds();
println!("Waiting for chain's past perfect time to reach {}...", now);
provider.wait_past_perfect_time(now as u64).await?;
println!("Perfect time reached. Transaction final and cannot be reversed.");
Ok(())
}