The purpose of this 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 Sway is a language under heavy development therefore the standards may not be the most ergonomic. Over time they should receive updates / improvements in order to demonstrate how Sway can be used in real use cases.
- SRC-20; Token Standard defines the implementation of a standard API for Native Assets using the Sway Language.
- SRC-2; Inline Documentation defines how to document your Sway files.
- SRC-3; Mint and Burn is used to enabling mint and burn functionality for Native Assets.
- SRC-5; Ownership Standard is used to restrict function calls to admin users in contracts.
To import a standard the following should be added to the project's Forc.toml
file under [dependencies]
with the most recent release:
standard = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.1.0" }
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 Token Standard use the following statement:
use src20::SRC20;
Note All standards currently use
forc v0.44.0
.
Note The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in these documents are to be interpreted as described in RFC 2119: https://www.ietf.org/rfc/rfc2119.txt