t4sk / hello-sway

learning sway

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Playground

TODO: - rewrite code targetting beta 3 testnet

TODO: - bridges

https://sway-playground.org/

Browser wallet

https://wallet.fuel.network/docs/install/

Install

https://github.com/FuelLabs/fuelup

rustup install stable
rustup update
rustup default stable

fuelup toolchain install latest

fuelup toolchain install beta-3
fuelup default beta-3

fuelup show
# switch
fuelup default latest

Update

fuelup self update

# generate test
cargo generate --init fuellabs/sway templates/sway-test-rs --name counter

New project

forc new counter_contract

# compile
forc build
# format
forc fmt

# node
fuel-core run --db-type in-memory
# deploy
forc deploy --unsigned

Apps

  • counter (storage)
  • ownership (Identity type, msg_sender, configurable, Option, Error, imports)
  • wallet (native assets, identity, access control, payable, output variables)
  • wrapped token (contract_id, msg_asset_id, mint, burn, transfer)
  • nft (log, nested storage map, private funcs, constant)
  • airdrop (sway-libs, events, multi abi, multi contracts, storage map, sha256, test events)
  • call (multiple contracts, call, low level call, calling other contracts (Rust SDK), fn_selector!)
  • multi-sig (multi token, vec on heap, multi abi, loop, storage vec, events, low_level_call, hash, recover sig)
  • otc (predicate)
  • bridge?
  • liquidity book - amm
  • uniswap v3 amm?
  • escrow
  • auction
  • queue (generics)
  • reentrancy guard?

Topcis

  • no inheritance, no constructor, global memory, native assets, no for loop, utxo

  • deploy to testnet

  • sway lib

  • default values

  • program types overview

  • basic

    • variables (immutable, mut, type annotations)
    • built-in
      • primitive types (u64, bool, str[], b256)
      • compound type (tuple, struct, array)
    • blockchain types
    • functions (return outputs, ref mut)
    • structs
    • tuples
    • enums
    • constants
    • configurable constants
    • std lib types - option
    • std lib types - result
    • control flow
      • if
      • match
      • while loop
    • logging
  • blockchain

    • msg_sender (ownership)
    • base asset (wallet)
    • native support for assets (wrapped token)
    • events
    • storage map (simple, nested)
    • vector (storage, heap) (nft)
    • hashing and cryptography (air drop)
    • function purity
    • identifier
    • calling contracts
  • advanced

    • methods
    • generics
    • traits
    • assembly
  • collections

    • vector on heap
    • vector and map
  • Testing (unit, integration)

  • Frontend

  • Deploy, node

  • wallet

  • inheritance?

  • assert, require, revert

  • program types (contract, library, scripts, predicates)

About

learning sway


Languages

Language:Rust 54.6%Language:Sway 45.4%