Code Monkey home page Code Monkey logo

sway-libs's Introduction

SwayLibs logo

Overview

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.

Libraries

  • 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.

Using a library

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;

Running Tests

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 and fuel-core 0.20.3.

Contributing

Check out the book for more info!

sway-libs's People

Contributors

bitzoic avatar rostyslavtyshko avatar nfurfaro avatar braqzen avatar swaystar123 avatar brandonsurh avatar jtriley-eth avatar adlerjohn avatar mehtavishwa30 avatar mitchmindtree avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.