This repo contains 1:1 examples showing how to implement example Solidity code in Sway.
A basic contract that stores a variable greeting
, and has a function to return the value of that variable.
This contract stores a variable called counter
in persistent storage, and has two functions: count
which reads the value of counter
, and increment
which adds 1 to the current value of counter
.
This contract logs the number 42
and the string Hello World!
whenever someone calls the logger
function.
This contract stores five types of state variables: a number, a string, a boolean, a map, and an array. It has functions to read and update their values.
This contract just includes some simple conditional logic to demonstrate the syntax.
A Todo
contract that stores a persistent array of Todo
structs, and has functions to create a new Todo
, get the value of one, and update an existing one.
This contract demonstrates a few ways to throw errors.
A contract with internal and external functions.
This contract shows the units used for amounts of ether.
This contract shows how to access the message sender and message amount sent in a transaction.
This contract shows how to access information about the gas used in a transaction.
This contract shows how to access the contract's balance and id.
This contract shows how to access information about the current block.
This contract shows the methods available to transfer assets.
A contract that mint tokens.
A contract that uses sha256 and keccack256 hashing.
This contract shows how to recover a public key from a signed message.
A contract that includes a guard against a re-entrancy attack.
This contract shows how unsigned integers are handled beyond the native max of u64