I've been trying to implement cross contract calls in constrcutor but somehow I can't seem to make it right. Is the following code executable?

pub mod contract {
  #[derive(Default, Storage)]
  pub struct LpToken { ... }
  impl LpToken {
    pub fn new(token: AccountId) {
      # here!!
      let base_name = PSP22MetadataRef::token_name(&token);
      let base_symbol = PSP22MetadataRef::token_symbol(&token);
      let decimals = PSP22MetadataRef::token_decimals(&token);

I could not find any docs on cross-contract calls in constructors. I would appreciate your help in this matter.

  • 2
    should be correct, did you run into some problem with this code?
    – kriko.eth
    Commented Mar 25, 2023 at 14:46
  • Do you get an error at compile time or at runtime? If at runtime: What does the Contracts UI display as an error?
    – cmichi
    Commented Mar 27, 2023 at 6:34
  • Code looks ok, but full code would be better to understand your issue. Do you have one message call and does your constructor return the contract instance?
    – Maario
    Commented Mar 27, 2023 at 7:34

1 Answer 1


With the given information it's not possible to answer the question at a level of detail that will help you. You should provide the information that people asked for in the comments, then we can help you properly.

That being said, the high-level answer is: yes, you can make a cross-contract call in a constructor.

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.