Coder Social home page Coder Social logo

sway-applications's Introduction

SwayApps logo

Overview

The purpose of this repository is to contain end-to-end applications that are written in Sway in order to demonstrate what can be built.

This means that a project will generally consist of a Sway contract and a user interface in order to interact with the contract however that is not a hard rule.

Note Sway is a language under heavy development therefore the applications 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.

Repository Structure

Each project within this repository is independent of the other projects and thus every project has its own directory with all of the files required to make it work.

That being said they are all under the same CI so any updates to a project must make sure that the other projects continue to pass.

The following is a visual sample of how the repository is structured.

sway-applications/
├── Project-1
|    └── P-1 Directories & files
├── Project-2
|    └── P-2 Directories & files
├── LICENSE
└── README.md

Projects

Asset Management

  • Airdrop is an asset distribution program where users are able to claim assets given a valid merkle proof.
  • Escrow is a third party that keeps an asset on behalf of multiple parties.
  • Non-Fungible Native Asset (NFT) is an asset contract which provides unique collectibles, identified and differentiated by IDs, where assets contain metadata giving them distinctive characteristics.
  • Fractional Non-Fungible Token (F-NFT) is a token contract which issues shares or partial ownership upon locking an NFT into a vault.
  • Timelock is a contract which restricts the execution of a transaction to a specified time range.
  • Native Asset is a basic asset contract that enables the use of Native Assets on Fuel using existing standards and libraries.

Decentralized Finance

  • English Auction is an auction where users bid up the price of an asset until the bidding period has ended or a reserve has been met.
  • Fundraiser is a program allowing users to pledge towards a goal.
  • OTC Swap Predicate is a predicate that can be used to propose and execute an atomic swap between two parties without requiring any on-chain state.

Governance

Other

  • Counter-Script is a script that calls a contract to increment a counter.
  • Name-Registry allows users to perform transactions with human readable names instead of addresses.
  • Oracle is a smart contract that provides off-chain data to on-chain applications.

Games

  • TicTacToe is a game where two players compete to align three markers in a row.

Low maintenance

The below apps are updated to the latest version, but may have broken tests or broken functionality. Use at your own discretion.

  • Automated Market Maker (AMM) is a decentralized exchange protocol that manages liquidity pools supplied by its users and determines prices algorithmically while exchanging assets.

Running a project

If you wish to run any of the projects then clone this repository and go through the general installation steps required to use our tools.

Any instructions related to running a specific project will be found within the README.md in the root of that project.

The projects are pinned to specific versions which can be seen at the top of the README.md inside the /<app>/project directory and inside the fuel-toolchain.toml.

Contributing

Check out the book for more info!

sway-applications's People

Contributors

adlerjohn avatar alicanc avatar bitzoic avatar brandonsurh avatar braqzen avatar collinwootan avatar fgimenez avatar flipflopapp avatar geckosplat avatar haadfida avatar hal3e avatar hummusonrails avatar k1-r1 avatar kaisersakhi avatar kirito-excalibur avatar luizstacio avatar matt-user avatar miles-six avatar nfurfaro avatar niravprajapati1 avatar omahs avatar pandabadger avatar rubyt0x avatar samantatarun avatar simonr0204 avatar supiket avatar swaystar123 avatar toofooboo avatar voxelot avatar x86cow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sway-applications's Issues

NFT Auctions

Application Description

Related: #47

Application which allows a user to specify the type of auction for their NFT sale.
This would allow the user to choose between a dutch auction, english auction and a blind auction.

Motivation

An NFT can have a value set inside of it for a sale and that value may be static.

Alternatively, an auction mechanism may be used to allow the market to choose the price for the NFT (barring some restrictions such as a minimum and maximum price).

Features

Additional context

cc @bitzoic

Multisig frontend

In order to interact with the multi-signature wallet in a user friendly manner a user interface should be created.

Contract

Transferring assets can be done to outputs and contracts.

This issue is meant to support transfers from the contract to another contract.

Supports 1-25 signatures

The wallet should be able to support an arbitrary number of signers meaning that we do not hardcode up to 25 variables in storage for the signers.

In this instance the goal is 1-25 signers.

Weighted signers

A weight of a signer is the number of approvals that they "give" when they approve a Tx.

A basic application is where each signer has a weight of 1 approval (their own) and thus if there are 5 signers with an approval threshold of 3 then 3 signers must approve the Tx.

This issue specifies that a signer can have a greater approval than 1 and thus it would be possible to approve a Tx (in the aforementioned example) with only 2 signers.

Multi-Signature Wallet Application

This issue is meant to document the various sub tasks that are required in order to create a fully functional multi-signature wallet written in Sway.

There are various components and they are grouped into categories.

The Basics

Ethereum Signature Capability

Frontend

Contract Calls

Documentation

Fundraiser frontend

Requirements

  1. As an author I should have an option to create a new crowdfund / fundraiser which allows me to specify
    • The asset that I want to use for people to pledge
    • The amount of asset required to reach the goal
    • The deadline after which the crowdfund is locked
  2. As an author I should be able to share my crowdfund with others via a link to a page
    • This page should demonstrate the required asset
    • The current amount pledged by everyone and the goal
    • The deadline
    • Should allow someone to pledge any amount from their wallet of the specified asset & also withdraw
  3. As an author I should be able to see all of my past and current fundraisers and their status.

Comprehensive documentation in the code

Simply writing code that is functional is insufficient and as such we need to document the Sway code once the multi-signature wallet has been created and passed extensive testing.

The purpose is not just a functional contract but knowledge transfer to future Sway developers.

Create Issue Templates

GitHub allows us to create templates for new issues.
These should be implemented to aid contributors in submitting issues because a guide is likely to lead to greater detail rather than a blank and unstructured page.

Escrow Application

This issue is meant to document the creation of a new application namely an Escrow.

Features

Create a CONTRIBUTING.md

The README.md contains some info about contributing however that is the incorrect place to store such information.
Moreover, it is not particularly descriptive.
Expand on the contributions in this file.

Create and add myself to CODEOWNERS file under `.github/CODEOWNERS`

Why should this feature be added?

It will automatically add me as a reviewer to any PR in the repository. It makes it easier to submit PRs for everyone.

Specification

Create a new CODEOWNERS file and append * @Braqzen with a new line at the end

Additional context

No response

Use a nonce to prevent double spends

Once a Tx has reached the required number of approvals it can be executed.

The nonce is meant to prevent multiple executions which could result e.g. having funds sent multiple times to an address until a contract is drained of an asset.
The execution should only be played out at most once and never again.

Improve the README.md

The current README.md has some basic info and it is mixed with CONTRIBUTING.md.

It should be split to contain a banner, badges, clearer explanation of the applications in the repository and how to navigate them etc.

Call contracts without knowing their ABI at compile time of the multisig

Once a Tx has been approved past a threshold it should be executable.

In order to accomplish execution we need to be able to call arbitrary contracts without knowing anything about them at the compilation of the multi-signature wallet.
This means that we need to be able to make generic calls at runtime.

English auction program

An English auction is one where the auctioneer sets an opening price and a reserve price that must be met in order to sell the item.
Bidders continue to place bids in order to be the highest bidder and the highest bidder will be the one the item is sold to if conditions are met.

Blind Auction program

A blind auction is where users can bid without others knowing their bid amounts. This is achieved with hashing (the value they want to bid, whether or not its a fake bid, and a secret) and sending that onto the chain. This hashed bid is later revealed, and if the deposits are greater than the value, and its a real bid, its accepted as a valid bid.
After the reveal period ends, the highest bidder wins.

solidity implementation

Move `logo.png` from the root of the project to a hidden `.docs` directory in the root

How does this improve a feature?

It removes unnecessary clutter from the perspective of the user.
They do not need to see this file in the root as it has nothing to do with why they would be browsing this repository.
This will make it slightly easier to navigate the repository since there will be less to click / "take in".

Specification

Creates a .docs directory in the root of the repository and places the logo.png there.
An update to the README.md is also required so that the correct path continues to point at the logo.

Additional context

Tuturu.

General purpose NFT contract

WIP

A general purpose NFT contract that will have the following attribute:

  • the contract should represent a collection of NFTs, not just a single token
  • every token minted should have a unique, immutable token id
  • there should be a way to find the owner of any token given its id.
  • access control for minting - the contract should store an Identity as the minter, which allows for either an address or a minter contract to be set as the entity with minting rights
  • an event should be emitted when approvals are made, an NFT is minted or burned, and when transfers are made

The contract ABI will follow the format below:

fn allowMint(minter: Identity) -> bool;
fn approve(to: Identity, token_id: b256) -> bool;
fn balance_of(owner: Identity) -> u64;
fn burn(token_id: b256) -> bool ;
fn constructor(owner: Identity, access_control: bool, token_count: u64) -> bool;
fn getApproved(token_id: b256) -> Identity;
fn getTotalSupply() -> u64;
fn isApprovedForAll(owner: Identity, operator: Identity) -> bool;
fn mint(to: Identity, amount: u64) -> bool ;
fn owner_of(token_id: b256) -> Option<Identity>;
fn setApprovalForAll(owner: Identity, operator: Idenity) -> bool;
fn transferFrom(from: Identity, to: Identity, token_id: b256) -> bool;

User interface for English auction

The user interface should allow the owner of an NFT to create an auction.

The auction should be shareable so that any user can place a bid
The owner should be able to see all of their auctions and their state.

Counter Tutorial Example

Application Description

A simple smart contract for a counter which has a user interface.

Motivation

The repository consists of end-to-end applications however tutorial applications should be added in order to walk a user through the creation process of decentralised applications.

A simple counter example could be the first application to go under a new path of sway-applications/tutorials/counter

Features

  • Sway counter contract
  • Contract tests
  • User interface
  • Tutorial Docs
  • CI: static analysis
  • Update base Readme

Additional context

cc @camsjams edit the issue as needed - especially the features (+new issues).

Create a fundraiser program that is fully tested

Requirements

  1. As an author I should be able to
    • Specify the asset that is used to measure against a target goal amount
    • Specify how long the crowdfund will last
    • Claim the amount once the goal is reached
  2. As a non-author I should be able to
    • Pledge any amount of the specified asset if the fund has not expired
    • Withdraw my pledge at any point after my pledge unless the goal has been reached

Extension: The contract should be a single contract that can spawn any number of independent fundraisers / campaigns. This can be done via handling data through various mappings.

Fundraiser Application

Application Description

Sway smart contract similar to an escrow, also has a user interface.

Users can deposit a specified asset to the contract within a specified time range.

  1. If the total sum pledged meets the goal then the author can claim the funds and automatically close the contract
  2. Otherwise everyone can withdraw their pledge

Motivation

It has a similar application to an Escrow and it is a viable real world use case via decentralized conditional funding.
A sway application should be created to demonstrate its usage.

Features

Additional context

Tuturu

Comprehensive documentation external to the codebase

Documenting the Sway code is a good start however there should be a user friendly page which takes the developer through the creation process and explains the intricacies beyond the functionality documented directly in the code.

Todo Tutorial Example

Application Description

A simple smart contract for a todo which has a user interface.

Motivation

The repository consists of end-to-end applications however tutorial applications should be added in order to walk a user through the creation process of decentralised applications.

A simple todo example should be added in sway-applications/tutorials/todo

Features

  • Sway Todo contract
  • Contract tests
  • User interface
  • Tutorial Docs
  • CI: static analysis
  • Update base Readme

Additional context

No response

Dutch auction program

A Dutch auction is a type of auction where securities are priced via bids rather than the seller setting the price.
In this scenario, the seller sets a maximum price, which is lowered over time until all of the securities have been bid on.

Citation

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.