Deposit
Deposit test tokens on Arc testnet and wait for the attester to reflect the balance.
Example: deposit and confirm finalization
Section titled “Example: deposit and confirm finalization”use alloy_primitives::U256;use alloy_provider::network::{EthereumWallet, TxSigner};use alloy_provider::ProviderBuilder;use alloy_signer_local::LocalSigner;use std::str::FromStr;use std::time::{Duration, UNIX_EPOCH};use tides_core_types::TidesChainId;use trident_sdk::{envs, TridentClient};
#[tokio::main]async fn main() { println!("==== Trident deposit + confirmation walkthrough ====");
// Example config: adjust chain, rpc, token, and private key as needed. let chain_name = "arc-testnet"; let rpc = "https://rpc.testnet.arc.network"; let token = envs::testnet::arc_testnet::TEST_TOKEN; let private_key = "0xYOUR_TEST_PRIVATE_KEY"; let amount = U256::from(10u64).pow(U256::from(18u64));
println!("1) Prepare signer, attester client, and deployment metadata"); let signer = LocalSigner::from_str(private_key).expect("valid private key"); let mut client = TridentClient::connect_testnet() .await .expect("attester connect"); let deployment = client .get_deployment_by_name(chain_name) .unwrap_or_else(|| panic!("deployment '{}' not found", chain_name)) .clone(); let chain_id = deployment.chain_id as TidesChainId;
println!("2) Bind a provider to the signer for approvals + deposits"); let provider = ProviderBuilder::new() .wallet(EthereumWallet::from(signer.clone())) .connect_http(rpc.parse().expect("rpc")); let recipient = TxSigner::address(&signer);
let balance_before = client .evm_balance(chain_id, recipient, token) .await .expect("balance before"); println!( " - Available balance before deposit on {}: {}", deployment.chain_name, balance_before );
println!("3) Approve and deposit the token amount into the Trident vault"); let deposit_result = client .evm_deposit_with_approval(&provider, chain_id, token, amount) .await .expect("deposit with approval"); println!( " - Deposit tx included in block {:?}", deposit_result.deposit_tx_receipt.block_number );
println!("4) Watch attester-reported balance until the deposit finalizes"); loop { let balance_after = client .evm_balance(chain_id, recipient, token) .await .expect("balance check");
println!( "[{}] Available amount on {}: {}", std::time::SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_millis(), deployment.chain_name, balance_after );
if balance_after > balance_before { println!(" - Deposit finalized and reflected in available balance"); break; }
println!(" - Deposit not finalized yet; waiting 10 seconds before re-checking"); tokio::time::sleep(Duration::from_secs(10)).await; }
println!("Done. Funds are now available for cross-chain spend requests.");}How it works
Section titled “How it works”Configure the request
Section titled “Configure the request”let chain_name = "arc-testnet";let rpc = "https://rpc.testnet.arc.network";let token = envs::testnet::arc_testnet::TEST_TOKEN;let private_key = "0xYOUR_TEST_PRIVATE_KEY";let amount = U256::from(10u64).pow(U256::from(18u64));Set the chain, RPC endpoint, token, private key, and deposit amount the walkthrough will use.
Connect to Trident and resolve deployment
Section titled “Connect to Trident and resolve deployment”let signer = LocalSigner::from_str(private_key).expect("valid private key");let mut client = TridentClient::connect_testnet() .await .expect("attester connect");let deployment = client .get_deployment_by_name(chain_name) .unwrap_or_else(|| panic!("deployment '{}' not found", chain_name)) .clone();let chain_id = deployment.chain_id as TidesChainId;Build the signer, connect to the testnet attester, and fetch deployment metadata (including chain_id) required for deposits and balance reads.
Bind provider and check starting balance
Section titled “Bind provider and check starting balance”let provider = ProviderBuilder::new() .wallet(EthereumWallet::from(signer.clone())) .connect_http(rpc.parse().expect("rpc"));let recipient = TxSigner::address(&signer);let balance_before = client .evm_balance(chain_id, recipient, token) .await .expect("balance before");Attach the signer to an HTTP provider for this chain and capture the attester-reported balance before depositing.
Approve and deposit
Section titled “Approve and deposit”let deposit_result = client .evm_deposit_with_approval(&provider, chain_id, token, amount) .await .expect("deposit with approval");Issue an approval and deposit in one call; the receipt includes the block where the deposit landed.
Wait for attester finalization
Section titled “Wait for attester finalization”loop { let balance_after = client .evm_balance(chain_id, recipient, token) .await .expect("balance check"); if balance_after > balance_before { println!(" - Deposit finalized and reflected in available balance"); break; } tokio::time::sleep(Duration::from_secs(10)).await;}Poll evm_balance until it exceeds the starting balance, indicating the attester has finalized the deposit and the funds are now spendable.