The purpose of this repository is to contain libraries which users can import and use that are not part of the standard library.
These libraries contain helper functions and other tools valuable to blockchain development.
Note Sway is a language under heavy development therefore the libraries 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.
- Binary Merkle Proof is used to verify Binary Merkle Trees computed off-chain.
- Ownership is used to apply restrictions on functions such that only a single user may call them.
- Reentrancy is used to detect and prevent reentrancy attacks.
- Signed Integers is an interface to implement signed integers.
- Fixed Point Number is an interface to implement fixed-point numbers.
- Queue is a linear data structure that provides First-In-First-Out (FIFO) operations.
- Token is a basic implementation of the SRC-20 and SRC-3 standards.
To import the Merkle Proof library the following should be added to the project's Forc.toml
file under [dependencies]
with the most recent release:
merkle_proof = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.1.0" }
You may then import your desired library in your Sway Smart Contract as so:
use merkle_proof::<library_function>;
For example, to import the Merkle Proof library use the following statement:
merkle_proof::binary_merkle_proof::verify_proof;
In order to run the tests make sure you are in the tests folder of this repository sway-libs/tests/<you are here>
.
Build the test projects:
forc build
Note This may take a while depending on your hardware, future improvements to Sway will decrease build times. After this has been run once, indiviual test projects may be built on their own to save time.
Run the tests:
cargo test
Any instructions related to using a specific library should be found within the README.md of that library.
Note All projects currently use
forc v0.46.0
,fuels-rs v0.46.0
andfuel-core 0.20.3
.
Check out the book for more info!