Skip to content

Commit

Permalink
chore: add more examlples
Browse files Browse the repository at this point in the history
  • Loading branch information
shamilsan committed Sep 14, 2023
1 parent b1b3c16 commit 33034e6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions docs/examples/feeds.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 7
# Introduction
In order to introduce our rapidly growing community to the platform developed by Gear, we've developed a dApplication in order to showcase some of the features that can be implemented using our smart contracts. Specifically, this contract aims to build a platform simillar to Twitter: each user can have their own "feed", "feeds" can be subscribed to and the landing page contains global & personal "feeds".

This article explains the programming interface, data structure, basic functions and explains their purpose. It can be used as is or modified to suit your own scenarios. Anyone can easily create their own application and run it on the Gear Network. The source code is available on [GitHub](https://github.com/gear-foundation/dapps-feeds).
This article explains the programming interface, data structure, basic functions and explains their purpose. It can be used as is or modified to suit your own scenarios. Anyone can easily create their own application and run it on the Gear Network. The source code is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/feeds).

# Feeds dApp composition
The application strcture consists of two smart contracts: the router contract and the channel contract. There's one router contract per application and one channel contract per user.
Expand All @@ -24,7 +24,7 @@ Let's now go through the flow of the application step by step.

First, channel owner should compile their own version of the contract filled in with information about the channel. Then, when the contract is uploaded to the network via the [Gear Idea portal](https://idea.gear-tech.io), owner of the contract should send a `Register` message to the router contract. Once router contract receives that message, it sends a `Meta` request to the recently deployed contract to verify that it has been set up correctly. If the channel contract responds properly, it is added to the list of available channels.

If you want to check out the code available for both the router and the channel contracts, you can find them here: [router](https://github.com/gear-foundation/dapps-feeds/tree/master/router), [channel](https://github.com/gear-foundation/dapps-gear-feeds-channel).
If you want to check out the code available for both the router and the channel contracts, you can find them here: [router](https://github.com/gear-foundation/dapps/tree/master/contracts/feeds/src), [channel](https://github.com/gear-foundation/dapps/tree/master/contracts/feeds/channel).

# The Gear Feeds website

Expand Down Expand Up @@ -73,7 +73,7 @@ extern "C" fn state() {
.expect("Failed to encode or reply with `<AppMetadata as Metadata>::State` from `state()`");
}
```
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `Channel` state. For example - [gear-foundation/dapps-feeds/channel-state](https://github.com/gear-foundation/dapps-feeds/tree/master/channel-state):
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `Channel` state. For example - [feeds/channel/state](https://github.com/gear-foundation/dapps/tree/master/contracts/feeds/channel/state):

```rust
#[metawasm]
Expand Down Expand Up @@ -117,7 +117,7 @@ extern "C" fn state() {
.expect("Failed to encode or reply with `<AppMetadata as Metadata>::State` from `state()`");
}
```
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `RouterState` state. For example - [gear-foundation/dapps-feeds/router-state](https://github.com/gear-foundation/dapps-feeds/tree/master/router-state):
To display only necessary certain values from the state, you need to write a separate crate. In this crate, specify functions that will return the desired values from the `RouterState` state. For example - [feeds/state](https://github.com/gear-foundation/dapps/tree/master/contracts/feeds/state):

```rust
#[metawasm]
Expand All @@ -141,6 +141,6 @@ pub trait Metawasm {
# Conclusion
Gear Feeds is an example of a full-fledged application with core logic being in a decentralized application implemented via Smart Contracts on Gear. We hope to see more exciting projects inspired by Gear feeds and recent platform improvements created by our community members! :)

The source code for both Channel and Router is available on [GitHub](https://github.com/gear-foundation/dapps-feeds).
The source code for both Channel and Router is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/feeds).

For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing).
12 changes: 6 additions & 6 deletions docs/examples/game-of-chance.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ sidebar_position: 9

Game of chance is a simple game smart contract with the lottery logic.

- Program source code available on [Github](https://github.com/gear-foundation/dapps-game-of-chance)
- dApp UI [Github](https://github.com/gear-foundation/dapps-game-of-chance/tree/master/frontend)
- Program source code available on [Github](https://github.com/gear-foundation/dapps/tree/master/contracts/game-of-chance)
- dApp UI [Github](https://github.com/gear-foundation/dapps/tree/master/frontend/game-of-chance)

## How to run

### ⚒️ Build program

- Get the source code of [GOC contract](https://github.com/gear-foundation/dapps-game-of-chance)
- Build contracts as described in [program/README.md](https://github.com/gear-foundation/dapps-game-of-chance/blob/master/README.md).
- Get the source code of [GOC contract](https://github.com/gear-foundation/dapps/tree/master/contracts/game-of-chance)
- Build contracts as described in [program/README.md](https://github.com/gear-foundation/dapps/blob/master/contracts/game-of-chance/README.md).

### 🏗️ Upload program

Expand All @@ -28,7 +28,7 @@ Game of chance is a simple game smart contract with the lottery logic.

### 🖥️ Run UI

1. Install packages as described in [frontend/README.md](https://github.com/gear-foundation/dapps-game-of-chance/blob/master/frontend/README.md)
1. Install packages as described in [frontend/README.md](https://github.com/gear-foundation/dapps/blob/master/frontend/game-of-chance/README.md)
2. Configure `.env` file. Specify network address and program ID like in the example below:

```sh
Expand Down Expand Up @@ -168,6 +168,6 @@ To display only necessary certain values from the state, you need to write a sep

## Source code

The source code of the Game of chance smart contract and an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps-game-of-chance). They can be used as is or modified to suit your own scenarios.
The source code of the Game of chance smart contract and an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/game-of-chance). They can be used as is or modified to suit your own scenarios.

For more details about testing smart contracts written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article.
2 changes: 1 addition & 1 deletion docs/examples/gft-20.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ These smart contracts can then be used to create tokenized assets that represent

These tokenized assets are known as fungible tokens as all instances of a given ERC-20 token are the same and they can be used interchangeably. A token that is unique and can not be interchangeable is known as a Non Fungible Token.

Gear provides native implementation of fungible token (gFT) described in this article. It explains the programming interface, data structure, basic functions and explains their purpose. It can be used as is or modified to suit your own scenarios. Anyone can easily create their own application and run it on the Gear Network. The source code is available on [GitHub](https://github.com/gear-foundation/dapps-sharded-fungible-token).
Gear provides native implementation of fungible token (gFT) described in this article. It explains the programming interface, data structure, basic functions and explains their purpose. It can be used as is or modified to suit your own scenarios. Anyone can easily create their own application and run it on the Gear Network. The source code is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/sharded-fungible-token).

The implementation of fungible token includes the following contracts:
- The `master` fungible token that serves as a proxy program that redirects the message to the logic contract;
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/gmt-1155.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A standard interface for contracts that manage multiple token types. A single de

The idea is simple and seeks to create a smart contract interface that can represent and control any number of fungible and non-fungible token types. In this way, the gMT token can do the same functions as gFT and gNFT token, and even both at the same time. Can be considered as analog of [ERC-1155](https://eips.ethereum.org/EIPS/eip-1155).

This article explains the programming interface, data structure, basic functions and explains their purpose. It can be used as is or modified to suit your own scenarios. Anyone can easily create their own application and run it on the Gear Network. The source code is available on [GitHub](https://github.com/gear-foundation/dapps-sharded-multitoken).
This article explains the programming interface, data structure, basic functions and explains their purpose. It can be used as is or modified to suit your own scenarios. Anyone can easily create their own application and run it on the Gear Network. The source code is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/sharded-multi-token).

## Architecture

Expand Down Expand Up @@ -478,6 +478,6 @@ pub struct InitMToken {

Gear provides a reusable library with core functionality for the gMT protocol. By using object composition, that library can be utilized within a custom gMT/MTK contract implementation in order to minimize duplication of community available code.

See also an example of the smart contract testing implementation based on `gtest` and `gclient`: [`sharded-multitoken/mt-main/tests`](https://github.com/gear-foundation/dapps-sharded-multitoken/tree/master/mt-main/tests).
See also an example of the smart contract testing implementation based on `gtest` and `gclient`: [`sharded-multi-token/tests`](https://github.com/gear-foundation/dapps/tree/master/contracts/sharded-multi-token/tests).

For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing).

0 comments on commit 33034e6

Please sign in to comment.