Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link

Icon LinkCore Library

The Sway Core Library, like the name suggests contains core operators and logic for the primitive types of the Sway programming language. These traits and methods are an extension of the primitive types Icon Link u8, u16, u32, u64, u256, str[], str, bool and , b256 and can be used where appropriate.

The latest core library documentation can be found here Icon Link. If the latest version is not compatible please refer to the appropriate tagged release.

Icon LinkUsing the Core Library

Core library functionalities do not need to be explicitly imported and will work out of the box after creating any new Sway project with forc new . The use keyword is simply not required.

Consider this example of using the modulo function for two like value types:

let val_1 = 10;
let val_2 = 2;
let result = val_1 % val_2;

Icon LinkCore Library Prelude

The prelude contains a list of operations essential to all Sway programs. The latest version of the prelude can be found here Icon Link.