The purpose of the Sway Standards repository is to contain standards for the Sway Language which users can import and use.
Standards in this repository may be in various stages of development. Use of draft standards and feedback on the proposed standards is encouraged. To use a draft, search for a standard using the appropriate GitHub label and implement the standard ABI into your contract.
If you don't find what you're looking for, feel free to create an issue and propose a new standard!
Note All standards currently use
forc v0.69.0
.
To import any standard, a dependency should be added to the project's Forc.toml
file under [dependencies]
.
[dependencies]
example = "0.0.0"
The standard you wish to use may be added as a dependency with the forc add
command. For example, to import the SRC-20 Standard, use the following forc
command:
forc add [email protected]
NOTE: Be sure to set the tag to the latest release.
You may then import your desired standard in your Sway Smart Contract as so:
use <standard>::<standard_abi>;
For example, to import the SRC-20 Native Asset Standard use the following statement in your Sway Smart Contract file:
use src20::SRC20;