Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add links to examples #39

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,50 @@ src_20 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.1.1" }
use src_20::SRC20;
```

### Examples of Standards

Minimal example implementations for every standard can be found in the [`examples/`](./examples/) folder.

#### SRC-20; Token Standard Examples

##### - [Single Native Assset](./examples/src_20/single_asset/src/single_asset.sw)

Example of the SRC-20 implementation where a contract contains a single asset with one `SubId`. This implementation is recommended for users that intend to deploy a single asset with their contract.

##### - [Multi Native Asset](./examples/src_20/multi_asset/src/multi_asset.sw)

Example of the SRC-20 implementation where a contract contains multiple assets with differing `SubId`s. This implementation is recommended for users that intend to deploy multiple assets with their contract.

#### SRC-3; Mint and Burn Standard Examples

##### - [Single Native Asset](./examples/src_3/single_asset/src/single_asset.sw)

Example of the SRC-3 implementation where a contract only mints a single asset with one `SubId`.

##### - [Multi Native Asset](./examples/src_3/multi_asset/src/multi_asset.sw)

Example of the SRC-3 implementation where a contract mints multiple assets with differing `SubId`s.

#### SRC-5; Ownership Examples

##### - [Uninitalized](./examples/src_5/uninitialized_example/src/uninitialized_example.sw)

Example of the SRC-5 implementation where a contract does not have an owner set at compile time with the intent to set it during runtime.

##### - [Initialized](./examples/src_5/initialized_example/src/initialized_example.sw)

Example of the SRC-5 implementation where a contract has an owner set at compile time.

#### SRC-7; Arbitrary Asset Metadata Standard Examples

##### - [Single Native Asset](./examples/src_7/single_asset/src/single_asset.sw)

Example of the SRC-7 implementation where metadata exists for only a single asset with one `SubId`.

##### - [Mutli Native Asset](./examples/src_7/multi_asset/src/multi_asset.sw)

Example of the SRC-7 implementation where metadata exists for multiple assets with differing `SubId`s.

> **Note**
> All standards currently use `forc v0.46.0`.

Expand Down
12 changes: 10 additions & 2 deletions standards/src_20/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset=".docs/src-20-logo-dark-theme.png">
<img alt="SRC-5 logo" width="400px" src=".docs/src-20-logo-light-theme.png">
<img alt="SRC-20 logo" width="400px" src=".docs/src-20-logo-light-theme.png">
</picture>
</p>

Expand Down Expand Up @@ -85,4 +85,12 @@ abi MyToken {
}
```

This draft standard is to be released as `v0.1`.
# Example Implementation

## [Single Native Assset](../../examples/src_20/single_asset/src/single_asset.sw)

Example of the SRC-20 implementation where a contract contains a single asset with one `SubId`. This implementation is recommended for users that intend to deploy a single asset with their contract.

## [Multi Native Asset](../../examples/src_20/multi_asset/src/multi_asset.sw)

Example of the SRC-20 implementation where a contract contains multiple assets with differing `SubId`s. This implementation is recommended for users that intend to deploy multiple assets with their contract.
10 changes: 9 additions & 1 deletion standards/src_3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,12 @@ abi MySRC3Token {
}
```

This draft standard is to be released as `v0.1`.
# Example Implementation

## [Single Native Asset](../../examples/src_3/single_asset/src/single_asset.sw)

Example of the SRC-3 implementation where a contract only mints a single asset with one `SubId`.

## [Multi Native Asset](../../examples/src_3/multi_asset/src/multi_asset.sw)

Example of the SRC-3 implementation where a contract mints multiple assets with differing `SubId`s.
27 changes: 13 additions & 14 deletions standards/src_5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,21 @@ There are no standards that SRC-5 requires to be compatible with.

The SRC-5 standard should help improve the security of Sway contracts and their interoperability.

# Examples
# Examples ABI

```rust
contract;

use std::constants::ZERO_B256;
use standards::src_5::*;

storage {
owner: State = Identity::Address(Address::from(ZERO_B256)),
}

impl SRC_5 for MyContract {
abi SRC5 {
#[storage(read)]
fn owner() -> State {
storage.owner.state
}
fn owner() -> State;
}
```

# Example Implementation

## [Uninitalized](../../examples/src_5/uninitialized_example/src/uninitialized_example.sw)

Example of the SRC-5 implementation where a contract does not have an owner set at compile time with the intent to set it during runtime.

## [Initialized](../../examples/src_5/initialized_example/src/initialized_example.sw)

Example of the SRC-5 implementation where a contract has an owner set at compile time.
12 changes: 11 additions & 1 deletion standards/src_7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,14 @@ abi SRC7Metadata {
#[storage(read)]
fn metadata(asset: AssetId, key: String) -> Option<Metadata>;
}
```
```

# Example Implementation

## [Single Native Asset](../../examples/src_7/single_asset/src/single_asset.sw)

Example of the SRC-7 implementation where metadata exists for only a single asset with one `SubId`.

## [Mutli Native Asset](../../examples/src_7/multi_asset/src/multi_asset.sw)

Example of the SRC-7 implementation where metadata exists for multiple assets with differing `SubId`s.
Loading