Unable to call mainnet contracts

Topic discussion checklist

  • Run $ fuelup show and add the output below:
Installed toolchains
--------------------
latest-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
testnet-x86_64-unknown-linux-gnu

active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (default)
 forc : 0.66.2+nightly.20241017.31486c0b47
   - forc-client
     - forc-deploy : 0.66.2+nightly.20241017.31486c0b47
     - forc-run : 0.66.2+nightly.20241017.31486c0b47
   - forc-crypto : 0.66.2+nightly.20241017.31486c0b47
   - forc-debug : 0.66.2+nightly.20241017.31486c0b47
   - forc-doc : 0.66.2+nightly.20241017.31486c0b47
   - forc-fmt : 0.66.2+nightly.20241017.31486c0b47
   - forc-lsp : 0.66.2+nightly.20241017.31486c0b47
   - forc-tx : 0.66.2+nightly.20241017.31486c0b47
   - forc-wallet : 0.11.0+nightly.20241017.152bfb48c3
 fuel-core : 0.40.0+nightly.20241017.eea8c60525
  • Detailed steps to recreate issue:
    I am using fuels-rs version 0.66.9 and since mainnet launch when i try to call a contract i get the error:
let swaylend_address = ContractId::from_str("0x657ab45a6eb98a4893a99fd104347179151e8b3828fd8f2a108cc09770d1ebae").unwrap();

    abigen!(Contract(
        name = "Swaylend",
        abi = "./swaylend-monorepo/out/market-abi.json"
    ));

    let provider = Provider::connect("mainnet.fuel.network").await.unwrap();
    let secret = SecretKey::from_str(&dotenv::var("SECRET_KEY").expect("no secret key in .env file"))?;
    let wallet = WalletUnlocked::new_from_private_key(secret, Some(provider.clone()));
    let methods = Swaylend::new(swaylend_address, wallet).methods();
    // This fails
    dbg!(methods.get_collateral_configurations().call().await?);
    Ok(())
}

The error is: Error: provider: io error: Response errors; not enough coins to fit the target
I get the same error when trying to call Mira contracts as well

Hey @soltheon, can you please try setting the default toolchain to latest instead of the nightly?

hey @naz3eh , still getting the same error after switching the toolachain to latest

the error seems to imply i don’t have enough coins to call the contract, but the function is read only. is there a special way to static call?

if i add an amount with CallParameters it returns: Error: assets forwarded to non-payable method

You are right. The error states that you do not have enough coins to make this call. However, you can make a read only call that simulates and does not require funds. Here is the docs:
https://rust.fuel.network/v0.66.9/calling-contracts/simulation.html

you need the .simulate(Execution::StateReadOnly)

1 Like

that worked. thank you

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.