Facing an issue while trying to query for a value in my contract. The value keeps getting retuned as null with an error. However, it works fine on substrate Contracts UI

Front end Dapp :

  const gasLimit = 3000n * 1000000n;
  // a limit to how much Balance to be used to pay for the storage created by the contract call
  // if null is passed, unlimited balance can be used
  const storageDepositLimit = null

  // Load the contract instance
  const Contract = new ContractPromise(api, abi, AlephsendContractAddress);
    // Perform a read of the contract's `get` message
  const callValue = await Contract.query.isPause("5HGn5UF5qdz8ShagwxRFSm387Hhd4wccAuVHZ17KtyyeUone",{

Contract function :

pub fn is_pause(&self) -> bool {
   return self.paused;

This is how my storage is defined :

#![cfg_attr(not(feature = "std"), no_std, no_main)]


mod aleph_send {

use openbrush::contracts::traits::psp22::{PSP22Ref,PSP22Error};
use openbrush::contracts::ownable::*;
use scale::alloc::vec::Vec;
use openbrush::traits::Storage;

#[derive(Default, Storage)]
pub struct Aleph {
        ownable: ownable::Data,
        pub fee    : Balance,
        pub paused : bool

impl Aleph {...contract code}

Any help would be much appreciated!

  • What error do you get?
    – Bobo K.
    Jul 25, 2023 at 12:31

2 Answers 2


I can't see what is wrong with your call, but let's try to fix it.

First be sure you have the proper metadata, see this previous StackExchange issue: How can you query a smart contract using the polkadot.js api?

You can try too if the result of the query has been ok like this:

const { result, output } = await Contract.query.isPause("5HGn5UF5qdz8ShagwxRFSm387Hhd4wccAuVHZ17KtyyeUone",{
// check if the call was successful
if (result.isOk) {
  // output the return value
  console.log('Success', output.toHuman());
} else {
  console.error('Error', result.asErr);

You have an example here: Reading contract values where it queries the incrementer smart contract.

And similar in this previous StackExchange Issue: How to get output when calling a contract method and signing it?

  • No luck. I even tried the out of the box example against the flipper contract and its still erroring out. How do contracts-ui.substrate.io do it? Doesn't seem to fail there
    – 0xD1x0n
    Jul 24, 2023 at 15:27

gasLimit should be of type WeighV2, not Weight. Try something like

const gasLimit = api.registry.createType(
) as WeightV2;

For querying a method this should be sufficient. If you want to execute transactions than you need to query a method first to get gas limits.

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.