What is the difference in these two approaches for cross contract calls? One uses the {Contract}Ref and the other uses the build_call().delegate() method. Both methods do not require the contract to be instantiated and only require the code hash.

let adder = AdderRef::new(accumulator.clone(), staker_code_hash)


                 .try_invoke() {
                     Ok(value) => value,
                     Err(err) => match err {
                         ink_env::Error::Decode(err) => panic!("Failed to decode return value: {:?}", err.to_string()),
                         _ => panic!("Failed to invoke `stake`"),
  • You are using build_call().delegate, but you can also use build_call().call which takes callee AccountId as a parameter and you do not need hash. docs.rs/ink_env/4.2.0/ink_env/call/… That makes build_call() to be more usable if you call already deployed contract.
    – Maario
    Commented May 29, 2023 at 16:51

1 Answer 1


You don't need the contract interface reference object in advance for using buil_call. You just pass the contract address with function selector and its parameter in low-level call format.

  • These 2 code snippets are both separate examples. They show 2 different methods for call cross contract. One approach uses the contract Ref and the other uses the code_hash for the delegate() method.
    – Snowmead
    Commented May 13, 2023 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.