As the title suggests, I'm trying to call a function on already deployed contract with a very simple String return function.
Deployed contract1 function:
#[ink(message)]
#[ink(selector = 0xDEADBEEF)]
pub fn test(&self) -> String {
return "TEST".to_string()
}
The following code snippet is the contract2 function, to return the value from contract1:
#[ink(message)]
pub fn test1(&self,token_contract: AccountId) -> String {
let my_return_value: String = ink_env::call::build_call::<ink_env::DefaultEnvironment>()
.callee(token_contract)
.gas_limit(50000)
.transferred_value(0)
.exec_input(
ink_env::call::ExecutionInput::new(ink_env::call::Selector::new([0xDE, 0xAD, 0xBE, 0xEF]))
)
.returns::<ink_env::call::utils::ReturnType<String>>()
.fire()
.unwrap();
my_return_value
}
This means that your sub contract, the one that is holding "pub fn test" has panicked.
The way to debug this is to start your substrate node with:
RUST_LOG=runtime=debug
This way you'll get the exact panic error in the substrate logs.
If you wish to handle the error in your caller contract build_call has map_err function. You can check their multisig example for code reference: https://github.com/paritytech/ink/blob/master/examples/multisig/lib.rs