Getting Error : The script reverted with reason Unknown

I am getting “The script reverted with reason Unknown error” when trying to call the contract function. What can be the reason?

Following is the contract function I am trying to access

#[storage(read)]
fn get_item(item_id: u64) -> Item{
    return storage.lease_map.get(item_id).try_read().unwrap();
}

This is how my javascript looks like:

 async getItem(itemId: string) {
    if (this.contractO != null) {
      let value = await this.contractO.functions
        .get_item(itemId)
        .callParams({
          gasLimit: 1,
        })
        .txParams({
          gasPrice: 1,
          gasLimit: 100_000,
        }).call();
      console.log(value)
      return value
    } else {
      return null
    }
  }

fuelup shows

installed toolchains

latest-x86_64-unknown-linux-gnu (default)

active toolchain

latest-x86_64-unknown-linux-gnu (default)
forc : 0.49.3
- forc-client
- forc-deploy : 0.49.3
- forc-run : 0.49.3
- forc-crypto : 0.49.3
- forc-doc : 0.49.3
- forc-explore : 0.28.1
- forc-fmt : 0.49.3
- forc-lsp : 0.49.3
- forc-tx : 0.49.3
- forc-wallet : 0.4.3
fuel-core : 0.22.1
fuel-core-keygen : 0.22.1

fuels versions

forc : 0.54.0
forc-wallet : 0.54.0

Hi, thanks for reporting.

What version of the TS SDK / fuels are you using?

1 Like

hi @anderson

Following are the versions

@fuel-ts/wallet”: “^0.73.0”,
@fuel-wallet/sdk”: “^0.16.1”,
“fuels”: “^0.76.2”,

I think you may have some version mismatch between your components.

Please try again by using fuels @ v0.73.0, and let me know how it goes.

{
  "fuels": "^0.73.0",
}

I tried with this but same error remaining

@fuel-ts/wallet”: “0.73.0”,
@fuel-wallet/sdk”: “0.15.2”,
“fuels”: “0.73.0”,

I sorted out this error. I tried lots of things but I guess it was fixed after I changing gasLimit to a higher number. (“fuels”: “0.73.0”,)

let value = await this.contractO.functions
.get_lease(leaseId)
.txParams({
gasPrice: 1,
gasLimit: 500_000,
}).call()

1 Like

Finally, I realized the reason for this error is, failing one of the condition validations I had created on my contract. Wondering how to get the actual validation error

1 Like

Thanks for letting me know. There are some ongoing efforts to provide better error messages for reverted transactions.

1 Like