The Sway standard library provides several utility types and methods we can use in our contract. To import a library, you can use the use
keyword and ::
, also called a namespace qualifier, to chain library names like this:
use std::auth::msg_sender;
You can also group together imports using curly brackets:
use std::{
auth::msg_sender,
storage::StorageVec,
}
For this contract, here is what needs to be imported. Copy this to your main.sw
file:
use std::{
auth::msg_sender,
call_frames::msg_asset_id,
context::{
msg_amount,
this_balance,
},
asset::transfer,
hash::Hash,
};
We'll go through what each of these imports does as we use them in the next steps.