Doubts about Fuel and Sway

Please answer my questions
It’s little urgent

here is the way to store string in struct

use std::string::String;

struct MyStruct {
    name: String,
}

impl MyStruct {
    fn new(name: String) -> Self {
        Self { name }
    }

    fn get_name(&self) -> String {
        self.name.clone()
    }
}

fn main() {
    let my_string = String::from_ascii_str("Fuel is blazingly fast");
    let my_struct = MyStruct::new(my_string);

    let stored_name = my_struct.get_name();
    log(stored_name);
}

  1. The identity type accepts both types of addresses, bech32 and b256. though i’d recommend using b256 as we are deprecating bech32.
  2. What do you mean, address to the function here?

you can also refer to sway by playground here

2 Likes

@Nazeeh21
3. I want to pass some address to this function.
so How can I pass the address

here is the example of a function where Identity type params is passed to a function. sway-applications/airdrop/airdrop-contract/src/main.sw at 806f9531eeffa0bba0a416adb476ab20fc853aa1 · FuelLabs/sway-applications · GitHub