Failure of Contact Data to display
⚓ Rust 📅 2025-10-04 👤 surdeus 👁️ 6Hello Rust Devs,
I am using alloy.rs to query my Solidity contract data but I get a display issue with the variable holding the results, with a warning that the variable can not be formatted with the default formatter, even the debug formatter doesn't work
use alloy::{providers::{Provider,ProviderBuilder}, primitives::address, sol};
use eyre::Result;
sol!(
#[sol(rpc)]
XFI_Safe_Binding,
"XFI_Safe_ABI.json"
);
#[tokio::main]
async fn main() -> Result<()>{
println!("Im querying XFI");
let XFI_Provider = ProviderBuilder::new().connect_http("https://rpc.mainnet.ms".parse()?);
let XFI_Chain_ID = XFI_Provider.get_chain_id().await?;
let XFI_Safe_Inst = XFI_Safe_Binding::new(
address!("0x1b5bbc25f41cbb4f77852c35e5bd422a7eb061aa"),
XFI_Provider,
);
let UnloadedData = XFI_Safe_Inst.unloadData().call().await?;
println!("The Chain ID is {}",XFI_Chain_ID);
// println!("This is the unloaded Data {:?}",UnloadedData);
Ok(())
}
UnloadedData over there, the println!() statement fails and the program panics with the error I mentioned earlier, otherwise when its commented out the compilation completes successfully.
unloadData method returns a tuple
function unloadData() external view returns(uint, uint, uint, uint, bool) {
if(withdrawInits[msg.sender] > 0 && int(withdrawThreshold-(block.timestamp + withdrawInits[msg.sender])) > 0){
return (
deposits[msg.sender],
withdrawnToInvest,
returnedfromInvestment,
withdrawThreshold-(block.timestamp + withdrawInits[msg.sender]),
true
);
} else {
return (
deposits[msg.sender],
withdrawnToInvest,
returnedfromInvestment,
0,
false
);
}
}
When I query a method that returns a singular value however, the value does display.
So i can't figure out when the issue is, I thought it might be a type mismatch with the binding for a tuple, but I can't resolve it. Someone help me understand why the tuple fails to display with all the formatters.
Here is the execution result, when the println statement is commented. first, and when its an active statement
Working result
Error results
2 posts - 2 participants
🏷️ Rust_feed

