use testcontainers::runners::SyncRunner;
use testcontainers_modules::anvil::{AnvilNode, ANVIL_PORT};
fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
let node = AnvilNode::default().start()?;
let port = node.get_host_port_ipv4(ANVIL_PORT)?;
let rpc_url = format!("http://localhost:{port}");
println!("Anvil node started successfully!");
println!("JSON-RPC endpoint: {rpc_url}");
println!();
println!("You can now connect to this endpoint using your Ethereum tooling:");
println!(" - cast: cast block-number --rpc-url {rpc_url}");
println!(" - web3: new Web3(new Web3.providers.HttpProvider('{rpc_url}'))");
println!(" - alloy: Provider::try_from('{rpc_url}')");
println!();
println!("Press Ctrl+C to stop the container");
std::thread::park();
Ok(())
}