Can you provide more detailed examples of contract calls

use fuels::prelude::abigen;

abigen!(Contract(abi = "abi.json", name = "Briged"));
proc macro panicked
message: called `Result::unwrap()` on an `Err` value: "invalid type: map, expected a sequence at line 2 column 4"

I want to know why. I’m sorry, I’m not very familiar with Rust

Hey @2575169674! Nice to see you in the Fuel community! I would highly recommend our Introduction to Sway for Javascript developers tutorial. The rust testing section specifically should be very useful to you.

Steps to replicate should goes as follows

  1. Once you have written and built your sway contract you should have your ABI json file within this path
    “out/debug/contract-abi.json” of your project
  2. Using the ABI generated with forc build you can then load it into your rust file similar to the line above.
abigen!(Contract(name="SwayStore", abi="out/debug/contract-abi.json"));
  1. You just need to create an instance using the loaded abi within your Rust code like so
    let instance = SwayStore::new(id.clone(), wallet);
  1. Finally you can reference your contract instance and make contract calls like this
    let (instance, _id, wallets) = get_contract_instance().await;
 
    // get access to a test wallet
    let wallet_1 = wallets.get(0).unwrap();
 
    // initialize wallet_1 as the owner
    let owner_result = instance
        .with_account(wallet_1.clone())
        .unwrap()
        .methods()
        .initialize_owner()
        .call()
        .await
        .unwrap();

Hope this helps!

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