From 8a6790b4ae0c2bfbc83eb7c99e912408b15bedac Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Tue, 19 Sep 2023 18:09:58 +0300 Subject: [PATCH 01/18] ap-dapps-links-update --- docs/examples/DAO.md | 28 ++-- docs/examples/concert.md | 8 +- docs/examples/crowdsale.md | 12 +- docs/examples/dein.md | 4 +- docs/examples/dex.md | 23 +-- docs/examples/dutch-auction.md | 28 ++-- docs/examples/dynamic-nft.md | 18 +-- docs/examples/escrow.md | 25 ++- docs/examples/feeds.md | 146 ------------------ docs/examples/game-of-chance.md | 14 +- docs/examples/gft-20.md | 6 +- docs/examples/gmt-1155.md | 2 +- docs/examples/gnft-4907.md | 22 +-- docs/examples/gnft-721.md | 35 +++-- docs/examples/monopoly.md | 14 +- docs/examples/multisig-wallet.md | 14 +- docs/examples/nft-marketplace/marketplace.md | 20 +-- .../nft-marketplace/nft-application.md | 10 +- docs/examples/nft-pixelboard.md | 2 +- docs/examples/onchain-nft.md | 17 +- docs/examples/oracle/dia-randomness-oracle.md | 2 +- docs/examples/ping.md | 28 +--- docs/examples/prerequisites.mdx | 6 +- docs/examples/rmrk.md | 5 +- docs/examples/rock-paper-scissors.md | 6 +- docs/examples/staking.md | 10 +- docs/examples/supply-chain.md | 18 +-- docs/examples/tequila-train.md | 10 +- docs/examples/varatube.md | 40 ++--- 29 files changed, 203 insertions(+), 370 deletions(-) delete mode 100644 docs/examples/feeds.md diff --git a/docs/examples/DAO.md b/docs/examples/DAO.md index f59eb7d42..8e026c61f 100644 --- a/docs/examples/DAO.md +++ b/docs/examples/DAO.md @@ -9,17 +9,17 @@ sidebar_position: 8 ### What is DAO -A decentralized autonomous organization, or a DAO for short, is a new type of way to run organizations or institutions that enable individuals to work together for a specific cause in transparent, fair and honest ways. DAOs can be thought of as online groups of like-minded individuals that are also collectively owned and managed by the members themselves in equitable ways. +A decentralized autonomous organization, or DAO for short, is a novel approach to managing organizations or institutions that enables individuals to collaborate for a specific cause in transparent, fair, and honest ways. DAOs can be likened to online communities of like-minded individuals, collectively owned and managed by their members in equitable ways. -Decisions are governed by proposals and votes to ensure that everyone within a decentralized autonomous organization has a voice. This is significant because it means that no central entity can manipulate anything for personal gain or based on personal beliefs. +Decisions are made through proposals and votes, ensuring that every member within a decentralized autonomous organization has a voice. This is significant because it prevents any central entity from manipulating matters for personal gain or based on personal beliefs. -DAOs offer safe alternatives to pooling together money for a particular cause. But this isn’t just money that can be ordinarily managed by members. For instance, a group could set up a DAO to govern a charity to begin accepting donations and distributing aid accordingly. However, by far the biggest use cases for DAOs at the moment have been decentralized investment funds. This is where a group of investors create a venture fund that pools capital together and votes transparently on where to allocate the capital. +DAOs provide secure alternatives for pooling funds for a particular cause. It's not limited to ordinary financial management by members. For example, a group could establish a DAO to oversee a charity, accepting donations and distributing aid in an accountable manner. However, the most prominent use cases for DAOs at the moment involve decentralized investment funds. In such scenarios, a group of investors establishes a venture fund that combines capital and transparently votes on its allocation. ### DAO application example by Gear -Anyone can easily create their own DAO application and run it on the Gear Network. To do this, Gear created an example of the DAO smart contract, which is available on [GitHub](https://github.com/gear-foundation/dapps-dao-light). +Anyone can easily create their own DAO application and run it on the Gear Network. To facilitate this, Gear has provided an example of the DAO smart contract, which is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/dao-light). -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. +This article explains the programming interface, data structure, basic functions, and their purposes. You can use it as-is or modify it to suit your own scenarios. @@ -121,7 +121,7 @@ The actions that the contract receives outside are defined in enum `DaoActions`. ### DAO functions -- Joining the DAO. In order to send the DAO contract the tokens and become the DAO members a user has to send the following message: +- Joining DAO. To join the DAO and become a DAO member, a user needs to send the following message to the DAO contract:" ```rust /// Deposits tokens to DAO @@ -157,7 +157,7 @@ SubmitFundingProposal { }, ``` - - The member or the delegate address of the member submits his vote (YES or NO) on the proposal. + - The member or the delegate address of the member submits their vote (YES or NO) on the proposal. ```rust /// The member submits a vote (YES or NO) on the proposal. @@ -176,7 +176,7 @@ SubmitVote { }, ``` - - The right for members to withdraw their capital during the grace period. It can be used when the members don’t agree with the result of the proposal and the acceptance of that proposal can affect their shares. The member can ragequit only if he has voted NO on that proposal. + - Members have the option to withdraw their capital during a grace period. This feature is useful when members disagree with the outcome of a proposal, especially if the acceptance of that proposal could impact their shares. A member can initiate a 'ragequit' only if they have voted 'NO' on the proposal. ```rust /// Withdraws the capital of the member @@ -193,7 +193,7 @@ RageQuit { }, ``` - - The proposal processing after the proposal competes during the grace period. If the proposal is accepted, the tribute tokens are deposited into the contract and new shares are minted and issued to the applicant. If the proposal is rejected, the tribute tokens are returned to the applicant. + - The proposal processing occurs after the proposal completes its grace period. If the proposal is accepted, the tribute tokens are deposited into the contract, and new shares are minted and issued to the applicant. In the event of rejection, the tribute tokens are returned to the applicant. ```rust /// The proposal processing after the proposal completes during the grace period. @@ -210,7 +210,7 @@ ProcessProposal { proposal_id: u128, }, ``` -- The ability to continue the transaction. Шf the transaction has not been completed due to network failure, the user can send a message `Continue` indicating the transaction id that needs to be completed: +- The option to resume the transaction is available. If a transaction hasn't been completed due to a network failure, the user can send a `Continue` message specifying the transaction ID that needs to be finalized: ```rust /// Continues the transaction if it fails due to lack of gas @@ -228,6 +228,8 @@ Continue( ## Consistency of contract states The `DAO` contract interacts with the `fungible` token contract. Each transaction that changes the states of DAO and the fungible token is stored in the state until it is completed. User can complete a pending transaction by sending a message `Continue` indicating the transaction id. The idempotency of the fungible token contract allows to restart a transaction without duplicate changes which guarantees the state consistency of these 2 contracts. +The `DAO` contract interacts with the `fungible token` contract. Every transaction that alters the states of the DAO and the fungible token is recorded in the state until it is finalized. Users can complete a pending transaction by sending a `Continue` message along with the transaction ID. The idempotency feature of the fungible token contract allows transactions to be restarted without duplicating changes, ensuring the state consistency of these two contracts. + diff --git a/docs/examples/concert.md b/docs/examples/concert.md index 6d5848061..b92ff2a5a 100644 --- a/docs/examples/concert.md +++ b/docs/examples/concert.md @@ -9,7 +9,7 @@ sidebar_position: 14 This smart contract example created by Gear represents a Concert tickets distribution with the idea of converting fungible tokens (gFT) to non-fungible tokens (gNFT) in time. -The 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-concert). +The 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/concert). In this example, a single deployed contract can hold one concert at a time. Firstly, all the tickets for the concert come as fungible-tokens. In order to buy tickets one should provide the metadata (e.g. seat/row number) that will later be included in NFTs. When the concert ends, all the fungible tokens of all users (ticket holders) will turn into NFTs. @@ -122,7 +122,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `State` struct. For example - [gear-foundation/dapps-concert/state](https://github.com/gear-foundation/dapps-concert/tree/master/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 `State` struct. For example - [concert/state](https://github.com/gear-foundation/dapps/tree/master/contracts/concert/state): ```rust #[metawasm] @@ -144,8 +144,8 @@ pub trait Metawasm { ``` ## Conclusion -A source code of the contract example provided by Gear is available on GitHub: [`concert/src`](https://github.com/gear-foundation/dapps-concert/tree/master/src). +A source code of the contract example provided by Gear is available on GitHub: [`concert/src`](https://github.com/gear-foundation/dapps/tree/master/contracts/concert/src). -See also an example of the smart contract testing implementation based on [gtest](https://github.com/gear-foundation/dapps-concert/tree/master/tests). +See also an example of the smart contract testing implementation based on [gtest](https://github.com/gear-foundation/dapps/tree/master/contracts/concert/tests). For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing). diff --git a/docs/examples/crowdsale.md b/docs/examples/crowdsale.md index a4231d933..746d80735 100644 --- a/docs/examples/crowdsale.md +++ b/docs/examples/crowdsale.md @@ -7,15 +7,15 @@ sidebar_position: 19 ## Introduction -A public offering to invest in a brand-new cryptocurrency or other digital asset is known as a cryptocurrency Crowdsale. A crowdsale can be used by new projects to raise money for development and other purposes. It is a time-limited campaign where investors can exchange their cryptocurrencies defined in the campaign to newly proposed tokens. The new tokens are promoted as future functional units after the crowdsale's funding goal is met and the project launches. +A public offering to invest in a brand-new cryptocurrency or other digital asset is known as a cryptocurrency crowdsale. A crowdsale can be used by new projects to raise money for development and other purposes. It is a time-limited campaign during which investors can exchange their cryptocurrencies, as defined in the campaign, for newly proposed tokens. These new tokens are promoted as future functional units once the crowdsale's funding goal is met, and the project launches. -An example of a crowdsale smart-contract implementation described in this article is one of many other decentralized applications that can be implemented and launched on Gear. 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 crowdsale application and run it on the Gear Network. +The example of a crowdsale smart contract implementation described in this article is just one of many decentralized applications that can be implemented and launched on Gear. This article explains the programming interface, data structure, basic functions, and their purposes. You can use it as-is or modify it to suit your own scenarios. Anyone can easily create their own crowdsale application and run it on a Gear-powered network. -Initial funds with which a token is purchased are determined by the Gear fungible tokens contract - [gFT](https://wiki.gear-tech.io/examples/gft-20). The contract's source code is available on [GitHub](https://github.com/gear-foundation/dapps-crowdsale). +The initial funds used to purchase a token are determined by the Gear fungible tokens contract - [gFT](gft-20). The contract's source code is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/crowdsale). ## Interface ### Source files -1. `messages.rs` - contains function of the fungible token contract. Crowdsale contract interacts with fungible token contract through transfer_tokens function: +1. `messages.rs` - contains function of the fungible token contract. Crowdsale contract interacts with the fungible token contract through `transfer_tokens` function: ```rust pub async fn transfer_tokens( transaction_id: u64, // - associated transaction id @@ -174,7 +174,7 @@ extern "C" fn 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 `State` state. For example - [gear-foundation/dapps-crowdsale/state](https://github.com/gear-foundation/dapps-crowdsale/tree/master/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 `State` state. For example - [gear-foundation/dapps-crowdsale/state](https://github.com/gear-foundation/dapps/tree/master/contracts/crowdsale/state): ```rust #[metawasm] @@ -198,6 +198,6 @@ pub trait Metawasm { ## Conclusion -The source code of this example of ICO smart contract and the example of an implementation of its testing is available on [Github](https://github.com/gear-foundation/dapps-crowdsale). +The source code of this example of ICO smart contract and the example of an implementation of its testing is available on [Github](https://github.com/gear-foundation/dapps/tree/master/contracts/crowdsale). For more details about testing smart contracts written on Gear, refer to the [Program Testing](https://wiki.gear-tech.io/developing-contracts/testing) article. diff --git a/docs/examples/dein.md b/docs/examples/dein.md index b096abde8..386b95d95 100644 --- a/docs/examples/dein.md +++ b/docs/examples/dein.md @@ -9,10 +9,10 @@ Decentralized Internet (DNS) demonstrates an on-chain server-less approach to we Briefly the solution consists of a DNS program that is uploaded on-chain. It lists programs (smart-contracts) that are also uploaded on-chain and registered in DNS contract as DNS records. Hosted programs may have the user interface that resides on IPFS. The DNS program stores program ids and meta info of their interfaces (name, description and link). -The source code of the smart contract and frontend implementation is available on [GitHub](https://github.com/gear-foundation/dapps-DeIn). +The source code of the smart contract and frontend implementation is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/ddns). Note that its repository contains a git submodule, so cloning should be done with the `--recurse-submodules` flag, i.e.: ``` -git clone --recurse-submodules "https://github.com/gear-foundation/dapps-DeIn" +git clone --recurse-submodules "https://github.com/gear-foundation/dapps/tree/master/contracts/ddns" ``` ## Connect your dApp to the Decentralized Internet diff --git a/docs/examples/dex.md b/docs/examples/dex.md index dd3aea858..cad832d35 100644 --- a/docs/examples/dex.md +++ b/docs/examples/dex.md @@ -6,12 +6,15 @@ sidebar_position: 21 # DEX (decentralized exchange) ## Introduction -A decentralized exchange (DEX for short) is a peer-to-peer marketplace where transactions occur directly between crypto traders. Unlike centralized exchanges like Binance, DEXs don’t allow for exchanges between fiat and crypto — instead, they exclusively trade cryptocurrency tokens for other cryptocurrency tokens. -Decentralized exchanges, on the other hand, are simply a set of smart contracts. They establish the prices of various cryptocurrencies against each algorithmically and use “liquidity pools” — in which investors lock funds in exchange for interest-like rewards — to facilitate trades. -While transactions on a centralized exchange are recorded on that exchange’s internal database, DEX transactions are settled directly on the blockchain. -DEXs are usually built on open-source code, meaning that anyone interested can see exactly how they work. That also means that developers can adapt existing code to create new competing projects — which is how Uniswap’s code has been adapted by an entire host of DEXs with “swap” in their names like Sushiswap and Pancakeswap. +A decentralized exchange (DEX, for short), is a peer-to-peer marketplace where transactions occur directly between cryptocurrency traders. Unlike centralized exchanges like Binance, DEXs don’t allow for exchanges between fiat and cryptocurrencies; instead, they exclusively trade cryptocurrency tokens for other cryptocurrency tokens. -The exchange uses [Gear fungible tokens (GFT-20)](/docs/examples/gft-20) underneath for the tokens and [Gear-lib FT wrapper](https://github.com/gear-foundation/dapps-gear-lib/tree/master/lib/src/fungible_token) for the pair to keep track of the liquidity. +Decentralized exchanges, on the other hand, are essentially a set of smart contracts. They establish the prices of various cryptocurrencies algorithmically and use "liquidity pools," in which investors lock funds in exchange for interest-like rewards, to facilitate trades. + +While transactions on a centralized exchange are recorded in that exchange's internal database, DEX transactions are settled directly on the blockchain. + +DEXs are usually built on open-source code, meaning that anyone interested can see exactly how they work. This also means that developers can adapt existing code to create new competing projects, which is how Uniswap's code has been adapted by a whole host of DEXs with "swap" in their names, such as Sushiswap and Pancakeswap. + +The exchange uses [Gear fungible tokens (GFT-20)](gft-20) underneath for the tokens and [Gear-lib FT wrapper](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib/src/tokens/fungible) for the pair to keep track of the liquidity. ### Math As it was said all the prices are algorithmically calculated. Investors provide funds to the liquidity pools and price is calculated according to the amount of tokens in the reserves using the following formula:

@@ -185,9 +188,9 @@ async fn create_pair(&mut self, mut token_a: ActorId, mut token_b: ActorId); ``` ### Source code -The source code of this example of DEX factory smart contract and the example of an implementation of its testing is available on [gear-foundation/dapps-dex/tree/master/factory](https://github.com/gear-foundation/dapps-dex/tree/master/factory). +The source code of this example of DEX factory smart contract and the example of an implementation of its testing is available on [gear-foundation/dapps-dex/tree/master/factory](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/factory). -See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-dex/tree/master/factory/tests](https://github.com/gear-foundation/dapps-dex/tree/master/factory/tests). +See also an example of the smart contract testing implementation based on `gtest`: [tests/utils/factory.rs](https://github.com/gear-foundation/dapps/blob/master/contracts/dex/tests/utils/factory.rs). For more details about testing smart contracts written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article. @@ -378,7 +381,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `State` struct. For example - [gear-foundation/dapps-dex/pair/state](https://github.com/gear-foundation/dapps-supply-chain/tree/master/pair/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 `State` struct. For example - [dex/state](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/state): ```rust #[metawasm] @@ -557,8 +560,8 @@ pub async fn swap_tokens_for_exact(&mut self, amount_out: u128, to: ActorId); ``` ### Source code -The source code of this example of DEX pair smart contract and the example of an implementation of its testing is available on [gear-foundation/dapps-dex/tree/master/pair](https://github.com/gear-foundation/dapps-dex/tree/master/pair). +The source code of this example of DEX pair smart contract and the example of an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/dex). -See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-dex/tree/master/pair/tests](https://github.com/gear-foundation/dapps-dex/tree/master/pair/tests). +See also an example of the smart contract testing implementation based on `gtest`: [dex/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/tests). For more details about testing smart contracts written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article. diff --git a/docs/examples/dutch-auction.md b/docs/examples/dutch-auction.md index 96d48619a..ead47ad13 100644 --- a/docs/examples/dutch-auction.md +++ b/docs/examples/dutch-auction.md @@ -6,11 +6,12 @@ sidebar_position: 11 # Dutch auction ## Introduction -A Dutch auction is one of several types of auctions for buying or selling goods. Most commonly, it means an auction in which the auctioneer begins with a high asking price in the case of selling, and lowers it until some participant accepts the price, or it reaches a predetermined reserve price. A Dutch auction has also been called a clock auction or open-outcry descending-price auction. This type of auction shows the advantage of speed since a sale never requires more than one bid. + +A Dutch auction is one of several types of auctions for buying or selling goods. Most commonly, it refers to an auction in which the auctioneer begins with a high asking price in the case of selling and gradually lowers it until some participant accepts the price or it reaches a predetermined reserve price. A Dutch auction has also been referred to as a clock auction or open-outcry descending-price auction. This type of auction demonstrates the advantage of speed since a sale never requires more than one bid. The auction uses [Gear non-fungible tokens (gNFT)](gnft-721.md) as tradable goods. -The 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-dutch-auction). +The article explains the programming interface, data structure, basic functions, and their respective purposes. 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/dutch-auction). ## Contract description @@ -29,7 +30,7 @@ pub enum Action { - `Create(CreateConfig)` is an action to create a new auction if the previous one is over or if it's the first auction in this contract.
- `ForceStop` is an action to force stop an auction if contract owner would prefer to finish it ahead of time ->Note how DutchAuction is composed; that allows users to reuse its functionality over and over again. +>Note how Dutch Auction is composed; that allows users to reuse its functionality over and over again. #### Structures in actions: @@ -44,12 +45,13 @@ pub struct CreateConfig { } ``` **To create a new auction you need to have these fields:** -- `nft_contract_actor_id` is a contract address where auctioneers NFT had been minted -- `token_owner` is an address of token owner to send him a reward if someone bought his NFT -- `token_id` is an id of NFT in its contract -- `starting_price` is the price at which the auction starts and starts descending -- `discount_rate` is the amount by which the price will decrease per millisecond over time -- `duration` is a property is needed to set the duration of the auction + +- `nft_contract_actor_id` is the contract address where the auctioneer's NFT has been minted. +- `token_owner` is the address of the token owner to whom a reward will be sent if someone buys their NFT. +- `token_id` is the ID of the NFT within its contract. +- `starting_price` is the initial price at which the auction begins and subsequently decreases. +- `discount_rate` is the rate at which the price decreases per millisecond over time. +- `duration` is a property that is needed to set the duration of the auction. ```rust pub struct Duration { @@ -88,7 +90,7 @@ pub enum Event { - `AuctionStoped` is an event that occurs when contract owner forcibly ends the auction ## Consistency of contract states -The `Dutch auction` contract interacts with the `non-fungible` token contract. Each transaction that changes the states of Dutch Auction and the non-fungible token is stored in the state until it is completed. User can complete a pending transaction by sending a message exactly the same as the previous one with indicating the transaction id. The idempotency of the non-fungible token contract allows to restart a transaction without duplicate changes which guarantees the state consistency of these 2 contracts. +The `Dutch auction` contract interacts with the `non-fungible token` contract. Each transaction that modifies the states of the Dutch Auction and the non-fungible token is stored in the state until it is completed. A user can finalize a pending transaction by sending a message that exactly matches the previous one while specifying the transaction ID. The idempotency of the non-fungible token contract allows for the restarting of a transaction without causing duplicate changes, ensuring the state consistency of these two contracts. ### Programm metadata and state Metadata interface description: @@ -115,7 +117,7 @@ extern "C" fn 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 `AuctionInfo` state. For example - [gear-foundation/dapps-dutch-auction/state](https://github.com/gear-foundation/dapps-dutch-auction/tree/master/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 `AuctionInfo` state. For example - [dutch-auction/state](https://github.com/gear-foundation/dapps/tree/master/contracts/dutch-auction/state): ```rust #[metawasm] @@ -134,8 +136,8 @@ pub mod metafns { ## Source code -The source code of this example of Dutch Auction smart contract and the example of an implementation of its testing is available on [gear-foundation/dapps-dutch-auction](https://github.com/gear-foundation/dapps-dutch-auction). +The source code of this example of Dutch Auction smart contract and the example of an implementation of its testing is available on [gear-foundation/dapps-dutch-auction](https://github.com/gear-foundation/dapps/tree/master/contracts/dutch-auction). -See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-dutch-auction/tree/master/tests](https://github.com/gear-foundation/dapps-dutch-auction/tree/master/tests). +See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-dutch-auction/tree/master/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/dutch-auction/tests). For more details about testing smart contracts written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article. diff --git a/docs/examples/dynamic-nft.md b/docs/examples/dynamic-nft.md index 766b15266..6f5422dec 100644 --- a/docs/examples/dynamic-nft.md +++ b/docs/examples/dynamic-nft.md @@ -6,7 +6,7 @@ sidebar_position: 5 # Gear Dynamic Non-Fungible Token ### Introduction -This is an extension of standard [Non-Fungible token](./gnft-721). It proposes an additional dynamic part that can change or evolve over time. The source code of the Gear NFT smart contract example is available on [GitHub](https://github.com/gear-foundation/dapps-dynamic-nft). +This is an extension of standard [Non-Fungible token](gnft-721). It proposes an additional dynamic part that can change or evolve over time. The source code of the Gear NFT smart contract example is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/dynamic-nft). ### Motivation @@ -16,13 +16,13 @@ This example demonstrates Gear Protocol's unique features enabling the new user ### Details -The default implementation of the NFT contract is provided in the gear library: [gear-lib/non_fungible_token](https://github.com/gear-foundation/dapps-gear-lib/tree/master/lib/src/non_fungible_token). +The default implementation of the NFT contract is provided in the Gear library: [/gear-lib/src/tokens/non_fungible.rs](https://github.com/gear-foundation/dapps/blob/master/contracts/gear-lib/src/tokens/non_fungible.rs). To use the default implementation you should include the packages into your *Cargo.toml* file: ```toml -gear-lib = { git = "https://github.com/gear-foundation/dapps-gear-lib.git" } -gear-lib-derive = { git = "https://github.com/gear-foundation/dapps-gear-lib.git" } +gear-lib = { git = "https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib.git" } +gear-lib-derive = { git = "https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib.git" } hashbrown = "0.13" ``` @@ -41,7 +41,7 @@ pub struct DynamicNft { pub dynamic_data: Vec, } ``` -In all other cases, everything also corresponds to the usual [non-fungible-token](./gnft-721) contract, except additional specific actions: +In all other cases, everything also corresponds to the usual [non-fungible-token](gnft-721) contract, except additional specific actions: ```rust #[derive(Debug, Encode, Decode, TypeInfo)] @@ -66,7 +66,7 @@ pub enum NFTEvent { ## Examples -For an example, look at this [Auto-changed NFT](https://github.com/gear-foundation/dapps-auto-changed-nft) contract. This is a modified dynamic contract in which own dynamic data changes over time periods. We slightly changed the logic of the dynamic NFT contract to suit our needs. +For an example, look at this [Auto-changed NFT](https://github.com/gear-foundation/dapps/tree/master/contracts/auto-changed-nft) contract. This is a modified dynamic contract in which own dynamic data changes over time periods. We slightly changed the logic of the dynamic NFT contract to suit our needs. First, let's change the name of the contract and add a new field `rest_update_periods` in which we store the rest update periods (in our example, we need 2 updates): @@ -189,10 +189,10 @@ Similarly, you can implement other logic, for example, periodically request data ## Conclusion -Gear provides a reusable [library](https://github.com/gear-foundation/dapps-gear-lib/tree/master/lib/src/non_fungible_token) with core functionality for the gNFT-4907 protocol. By using object composition, the library can be utilized within a custom NFT contract implementation in order to minimize duplication of community available code. +Gear provides a reusable [library](https://github.com/gear-foundation/dapps/blob/master/contracts/gear-lib/src/tokens/non_fungible.rs) with core functionality for the `gNFT-4907` protocol. By using object composition, the library can be utilized within a custom NFT contract implementation in order to minimize duplication of community available code. -A source code of the Gear NFT smart contract example based on `gear-lib` is available on GitHub: [gear-foundation/dapps-non-fungible-token](https://github.com/gear-foundation/dapps-dynamic-nft). +A source code of the Gear NFT smart contract example based on `gear-lib` is available on GitHub: [gear-foundation/dapps-non-fungible-token](https://github.com/gear-foundation/dapps/tree/master/contracts/dynamic-nft). -See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-non-fungible-token/tests](https://github.com/gear-foundation/dapps-dynamic-nft/tree/master/tests). +See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-non-fungible-token/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/dynamic-nft/tests). For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing). diff --git a/docs/examples/escrow.md b/docs/examples/escrow.md index 4089e3f25..59c96fbd2 100644 --- a/docs/examples/escrow.md +++ b/docs/examples/escrow.md @@ -6,10 +6,10 @@ sidebar_position: 9 ![img alt](./img/escrow.png) -An escrow is a special wallet to which some assets (e.g. money or stocks) are deposited and stored until certain conditions are met. In terms of smart contracts, an escrow is a wallet that is stored on a blockchain and, like a regular escrow, can receive some assets (e.g. a cryptocurrency or fungible tokens (like [Gear fungible tokens - gFT](gft-20.md) in this example)) from one user and, when certain conditions are met, send them to another. +An escrow is a special wallet to which certain assets (e.g., money or stocks) are deposited and stored until specific conditions are met. In terms of smart contracts, an escrow is a wallet stored on a blockchain that, like a traditional escrow, can receive assets (e.g., cryptocurrency or fungible tokens, such as [Gear fungible tokens - gFT](gft-20.md) in this example) from one user and, when certain conditions are met, send them to another. -- Program source code is avalible on [Github](https://github.com/gear-foundation/dapps-escrow) -- dApp UI [Github](https://github.com/gear-foundation/dapps-escrow/tree/master/frontend) +- Program source code is avalible on [Github](https://github.com/gear-foundation/dapps/tree/master/contracts/escrow) +- dApp UI [Github](https://github.com/gear-foundation/dapps/tree/master/frontend/escrow) ## How to run @@ -17,8 +17,8 @@ This video demonstrates how to configure and run Escrow application on your own ### ⚒️ Build program -- Get the source code of the [Escrow smart contract](https://github.com/gear-foundation/dapps-escrow) -- Build contract as described in [program/README.md](https://github.com/gear-foundation/dapps-escrow/blob/master/README.md). +- Get the source code of the [Escrow smart contract](https://github.com/gear-foundation/dapps/tree/master/contracts/escrow) +- Build contract as described in [program/README.md](https://github.com/gear-foundation/dapps/blob/master/contracts/escrow/README.md). ### 🏗️ Upload Сode @@ -30,7 +30,7 @@ This application requires code to create an escrow wallet ### 🖥️ Run UI -1. Install packages as described in [frontend/README.md](https://github.com/gear-foundation/dapps-escrow/blob/master/frontend/README.md) +1. Install packages as described in [frontend/README.md](https://github.com/gear-foundation/dapps/blob/master/frontend/escrow/README.md) 2. Configure .evn file. Specify network address and code ID like in the example below: ```sh @@ -46,16 +46,16 @@ yarn start ## Introduction -This article explains at a superficial level the purpose and logic of this smart contract. The source code of the smart contract example is available on [GitHub](https://github.com/gear-foundation/dapps-escrow). +This article explains at a superficial level the purpose and logic of this smart contract. The source code of the smart contract example is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/escrow). ## Logic * Any user can create an escrow wallet as a buyer or seller. -* A buyer can make a deposit or confirm a deal and close a wallet. +* A buyer can make a deposit or confirm a deal and close the wallet. * A seller can refund tokens from a paid wallet to a buyer. -* Both buyer and seller can cancel a deal and close an unpaid wallet. +* Both the buyer and the seller can cancel a deal and close an unpaid wallet. -One escrow wallet contains info about a `buyer`, a `seller`, wallet `state` and an `amount` of tokens that this wallet can store: +An escrow wallet contains information about a `buyer`, a `seller`, the wallet `state`, and the `amount` of tokens that this wallet can store: ```rust pub struct Wallet { @@ -191,8 +191,7 @@ pub enum EscrowAction { ``` ## Consistency of contract states -The `Escrow` contract interacts with the `fungible` token contract. Each transaction that changes the states of Escrow and the fungible token is stored in the state until it is completed. User can complete a pending transaction by sending a message `Continue` indicating the transaction id. The idempotency of the fungible token contract allows to restart a transaction without duplicate changes which guarantees the state consistency of these 2 contracts. - +The `Escrow contract` interacts with the `fungible token contract`. Each transaction that modifies the states of the Escrow and the fungible token is stored in the state until it is completed. A user can finalize a pending transaction by sending a Continue message, indicating the transaction ID. The idempotency of the fungible token contract allows for the restarting of a transaction without causing duplicate changes, ensuring the state consistency of these two contracts. ## Program metadata and state Metadata interface description: @@ -221,7 +220,7 @@ extern "C" fn state() { .expect("Failed to share 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 `Escrow` state. For example - [gear-foundation/dapps-escrow/state](https://github.com/gear-foundation/dapps-escrow/tree/master/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 `Escrow` state. For example - [gear-foundation/dapps-escrow/state](https://github.com/gear-foundation/dapps/tree/master/contracts/escrow/state): ```rust #[metawasm] diff --git a/docs/examples/feeds.md b/docs/examples/feeds.md deleted file mode 100644 index a15d787b2..000000000 --- a/docs/examples/feeds.md +++ /dev/null @@ -1,146 +0,0 @@ ---- -sidebar_label: Gear Feeds -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). - -# 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. - -The router contract has a very straightforward purpose: it records instantiation of new channel contracts and verifies their validity. Thus, it only contains one action: Register, which is invoked by the owner of a channel contract that needs to be added. - -The channel contract is a little more complex: it is responsible for handling posts being added to its feed, keeping track of subscribers and providing meta information about itself. - -# Interaction flow -Here's a schema of how the contracts are connected to each other: - -![img alt](./img/feeds-outline.png) - -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). - -# The Gear Feeds website - -The Demo Gear Feeds application is avaialble at **[https://workshop.gear-tech.io](https://workshop.gear-tech.io)**. - -First, log in using your [Polkadot.js extension wallet](https://polkadot.js.org/extension/). - -![img alt](./img/log-in.png) - -Now, you can browse a list of all channels. - -![img alt](./img/show-all.png) - -If you have uploaded your own contract under the same ID you've logged in to the website with, you should be able to see it under `my channel`. - -![img alt](./img/channels.png) - -When viewing your own channel, you can add posts to it (you will have to conduct a transaction). All the subscribers will see the posts in their personal feeds. - -![img alt](./img/my-channel.png) - -# Channel program metadata and state -Metadata interface description: - -```rust -pub struct ChannelMetadata; - -impl Metadata for ChannelMetadata { - type Init = (); - type Handle = InOut; - type Others = (); - type Reply = (); - type Signal = (); - type State = Channel; -} -``` -To display the full contract state information, the `state()` function is used: - -```rust -#[no_mangle] -extern "C" fn state() { - msg::reply( - unsafe { CHANNEL.clone().expect("Uninitialized channel state") }, - 0, - ) - .expect("Failed to encode or reply with `::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): - -```rust -#[metawasm] -pub trait Metawasm { - type State = ::State; - - fn all_messages(state: Self::State) -> Vec { - ... - } -} -``` - -# Router program metadata and state -Metadata interface description: - -```rust -pub struct RouterMetadata; - -impl Metadata for RouterMetadata { - type Init = (); - type Handle = InOut; - type Others = (); - type Reply = (); - type Signal = (); - type State = RouterState; -} -``` -To display the full contract state information, the `state()` function is used: - -```rust -#[no_mangle] -extern "C" fn state() { - msg::reply( - unsafe { - let router = ROUTER.as_ref().expect("Uninitialized router state"); - let state: RouterState = router.into(); - state - }, - 0, - ) - .expect("Failed to encode or reply with `::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): - -```rust -#[metawasm] -pub trait Metawasm { - type State = ::State; - - fn all_channels(state: Self::State) -> Vec { - ... - } - - fn channel(id: ActorId, state: Self::State) -> Channel { - ... - } - - fn subscribed_to_channels(id: ActorId, state: Self::State) -> Vec { - ... - } -} -``` - -# 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). - -For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing). diff --git a/docs/examples/game-of-chance.md b/docs/examples/game-of-chance.md index ba20c0a66..cbc13b528 100644 --- a/docs/examples/game-of-chance.md +++ b/docs/examples/game-of-chance.md @@ -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 @@ -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 @@ -48,7 +48,7 @@ yarn start For a more detailed technical description, see its [documentation on the dApps documentation portal](https://dapps.gear.rs/game_of_chance) and [the source code section](#source-code). ::: -During an initialization, the game administrator is assigned. It has the rights to start a new game round and pick a winner after the end of each one. Other actors can participate in a round if they have enough fungible tokens or the native value, they're used to collect prize funds. After the end of the players entry stage, the administrator should execute the action for picking a winner, and this smart contract does it randomly and then sends prize funds to the winner. +During initialization, the game administrator is assigned. The administrator has the rights to start a new game round and select a winner after the end of each one. Other actors can participate in a round if they have enough fungible tokens or the native value they use to contribute to the prize funds. After the players' entry stage ends, the administrator should execute the action to select a winner. This smart contract randomly selects the winner and then sends the prize funds to them. ## Interface @@ -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 are available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/frontend/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. diff --git a/docs/examples/gft-20.md b/docs/examples/gft-20.md index 9914870b9..95b1b66ba 100644 --- a/docs/examples/gft-20.md +++ b/docs/examples/gft-20.md @@ -10,18 +10,14 @@ sidebar_position: 3 ERC-20 is a standard that’s used for creating and issuing smart contracts on the Ethereum blockchain. It was created by Ethereum developers on behalf of the Ethereum community in 2015, and it was officially recognized in 2017. These smart contracts can then be used to create tokenized assets that represent anything on the Ethereum blockchain like: - - In-game currency - - Financial instruments like a share in a company - - Fiat currencies, like USD for example - - Ounces of Gold 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/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; diff --git a/docs/examples/gmt-1155.md b/docs/examples/gmt-1155.md index 65e677453..1fd8cc0eb 100644 --- a/docs/examples/gmt-1155.md +++ b/docs/examples/gmt-1155.md @@ -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/multi-token). ## Architecture diff --git a/docs/examples/gnft-4907.md b/docs/examples/gnft-4907.md index 88f079ca3..037bd462c 100644 --- a/docs/examples/gnft-4907.md +++ b/docs/examples/gnft-4907.md @@ -6,25 +6,25 @@ sidebar_position: 5 # Gear Rentable Non-Fungible Token ### Introduction -This is an extension of standard [Non-Fungible token](./gnft-721). It proposes an additional role (user) which can be granted to addresses, and a time where the role is automatically revoked (expires). The user role represents permission to "use" the NFT, but not the ability to transfer it or set users. The source code of the Gear NFT smart contract example is available on [GitHub](https://github.com/gear-foundation/dapps-rentable_nft). + +This is an extension of the standard [Non-Fungible Token (NFT)](gnft-721). It introduces an additional role (user) that can be granted to addresses, along with a predefined expiration time for this role. The user role grants permission to "use" the NFT, but it does not allow the ability to transfer it or set other users. The source code of the smart contract example is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/rentable-nft). ### Motivation -Some NFTs have certain utilities. For example, virtual land can be "used" to build scenes, and NFTs representing game assets can be "used" in-game. In some cases, the owner and user may not always be the same. There may be an owner of the NFT that rents it out to a “user”. The actions that a “user” should be able to take with an NFT would be different from the “owner” (for instance, “users” usually shouldn’t be able to sell ownership of the NFT). In these situations, it makes sense to have separate roles that identify whether an address represents an “owner” or a “user” and manage permissions to perform actions accordingly. +Some NFTs serve specific utilities. For instance, virtual land can be utilized to create scenes, and NFTs representing in-game assets can be used within the game. In some cases, the NFT's owner and user may not always be the same person. There might be an NFT owner who rents it out to a "user." The actions that a "user" can perform with an NFT differ from those of the "owner" (for example, "users" typically shouldn't have the ability to sell ownership of the NFT). In such situations, it is logical to establish distinct roles that determine whether an address represents an "owner" or a "user," and to manage permissions accordingly. -Some projects already use this design scheme under different names such as “operator” or “controller” but as it becomes more and more prevalent, we need a unified standard to facilitate collaboration amongst all applications. +Some projects already implement this design concept under various names, such as "operator" or "controller." However, as it becomes more widespread, there is a need for a standardized approach to encourage collaboration among all applications. -Furthermore, applications of this model (such as renting) often demand that user addresses have only temporary access to using the NFT. Normally, this means the owner needs to submit two on-chain transactions, one to list a new address as the new user role at the start of the duration and one to reclaim the user role at the end. This is inefficient in both labor and gas and so an “expires” function is introduced that would facilitate the automatic end of a usage term without the need of a second transaction. +Moreover, applications of this model, such as renting, often require that user addresses have only temporary access to use the NFT. Typically, this means the owner needs to execute two on-chain transactions: one to designate a new address as the user role at the beginning of the duration and another to reclaim the user role at the end. This process is inefficient in terms of both labor and gas costs. Therefore, an "expires" function is introduced to facilitate the automatic termination of a usage term without the need for a second transaction. ### Details -The default implementation of the NFT contract is provided in the gear library: [gear-lib/non_fungible_token](https://github.com/gear-foundation/dapps-gear-lib/tree/master/lib/src/non_fungible_token). +The default implementation of the NFT contract is provided in the gear library: [gear-lib/non_fungible_token](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib/src/tokens). To use the default implementation you should include the packages into your *Cargo.toml* file: ```toml -gear-lib = { git = "https://github.com/gear-foundation/dapps-gear-lib.git" } -gear-lib-derive = { git = "https://github.com/gear-foundation/dapps-gear-lib.git" } +gear-lib = { git = "https://github.com/gear-foundation/dapps", tag = "0.3.3" } hashbrown = "0.13.1" ``` @@ -43,7 +43,7 @@ pub struct Nft { pub users_info: HashMap, } ``` -In all other cases, everything also corresponds to the usual [non-fungible-token](./gnft-721) contract, except additional specific actions: +In all other cases, everything also corresponds to the usual [non-fungible-token](gnft-721) contract, except additional specific actions: ```rust #[derive(Debug, Encode, Decode, TypeInfo)] @@ -84,10 +84,10 @@ pub enum NFTEvent { ## Conclusion -Gear provides a reusable [library](https://github.com/gear-foundation/dapps-gear-lib/tree/master/lib/src/non_fungible_token) with core functionality for the gNFT-4907 protocol. By using object composition, the library can be utilized within a custom NFT contract implementation in order to minimize duplication of community available code. +Gear provides a reusable [library](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib) with core functionality for the gNFT-4907 protocol. By using object composition, the library can be utilized within a custom NFT contract implementation in order to minimize duplication of community available code. -A source code of the Gear NFT smart contract example based on `gear-lib` is available on GitHub: [gear-foundation/dapps-non-fungible-token](https://github.com/gear-foundation/dapps-rentable_nft). +A source code of the Gear NFT smart contract example based on `gear-lib` is available on GitHub: [gear-foundation/dapps-non-fungible-token](https://github.com/gear-foundation/dapps/tree/master/contracts/rentable-nft). -See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-non-fungible-token/tests](https://github.com/gear-foundation/dapps-rentable_nft/tree/master/tests). +See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-non-fungible-token/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/rentable-nft/tests). For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing). diff --git a/docs/examples/gnft-721.md b/docs/examples/gnft-721.md index 16c7c6800..1147e593d 100644 --- a/docs/examples/gnft-721.md +++ b/docs/examples/gnft-721.md @@ -7,23 +7,20 @@ sidebar_position: 4 ![img alt](./img/nft.png) -Non-fungible tokens (NFTs) are unique cryptographic tokens on a blockchain that are used to prove an ownership of a digital asset, such as digital art or gaming assets. The difference from fungible tokens is that the fungible tokens store a value, while non-fungible tokens store a cryptographic certificate. +Non-fungible tokens (NFTs) are unique cryptographic tokens on a blockchain used to prove ownership of digital assets, such as digital art or gaming assets. The difference from fungible tokens is that fungible tokens store value, while non-fungible tokens store a cryptographic certificate. -Under the hood, a non-fungible token consists of a unique token identifier, or token ID, which is mapped to an owner identifier and stored inside a NFT smart contract.
token_idaddress
+Under the hood, a non-fungible token consists of a unique token identifier, or token ID, which is mapped to an owner identifier and stored inside an NFT smart contract.
token_idaddress
When the owner of a given token ID wishes to transfer it to another user, it is easy to verify ownership and reassign the token to a new owner. -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. +This article explains the programming interface, data structure, basic functions, and their purposes. It can be used as-is or modified to suit your scenarios. Anyone can easily create their own application and run it on the Gear-powered network. ## How to run -- Program source code available on [Github](https://github.com/gear-foundation/dapps-non-fungible-token) -- dApp UI [Github](https://github.com/gear-foundation/dapps-non-fungible-token/tree/master/frontend) - ### ⚒️ Build program -- Get the source code of [NFT contract](https://github.com/gear-foundation/dapps-non-fungible-token) -- Build contracts as described in [program/README.md](https://github.com/gear-foundation/dapps-non-fungible-token/blob/master/frontend/README.md). +- Get the source code of [NFT contract](https://github.com/gear-foundation/dapps/tree/master/contracts/non-fungible-token) +- Build contracts as described in [program/README.md](https://github.com/gear-foundation/dapps/blob/master/contracts/non-fungible-token/README.md). ### 🏗️ Upload program @@ -42,8 +39,11 @@ royalties `Option` - Optional param to specify accounts to pay royalt ### 🖥️ Run UI -1. Install packages as described in [frontend/README.md](https://github.com/gear-foundation/dapps-non-fungible-token/blob/master/frontend/README.md) -2. Configure .evn file. Specify network address and program ID like in the example below: +1. Download the React application repository from [GitHub](https://github.com/gear-foundation/dapps/tree/master/frontend/non-fungible-token). + +2. Install packages as described in [frontend/README.md](https://github.com/gear-foundation/dapps/blob/master/frontend/non-fungible-token/README.md) + +3. Configure .evn file. Specify network address and program ID like in the example below: ```sh REACT_APP_NODE_ADDRESS=wss://node-workshop.gear.rs:443 @@ -52,7 +52,7 @@ REACT_APP_IPFS_GATEWAY_ADDRESS=https://ipfs-gw.gear-tech.io/ipfs REACT_APP_CONTRACT_ADDRESS=0xdf7b9b10240f827f112da757bb68eb301ee873d6c1015855220f2122996540c4 ``` -3. Run app +4. Run app ```sh yarn start @@ -66,13 +66,12 @@ The functions that must be supported by each non-fungible-token contract: - *mint(to, token_id, metadata)* is a function that creates a new token. Metadata can include any information about the token: it can be a link to a specific resource, a description of the token, etc; - *burn(from, token_id)* is a function that removes the token with the mentioned *token_id* from the contract. -The default implementation of the NFT contract is provided in the gear library: [gear-lib/non_fungible_token](https://github.com/gear-foundation/dapps-gear-lib/tree/master/lib/src/non_fungible_token). +The default implementation of the NFT contract is provided in the Gear library: [gear-lib/non_fungible_token](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib/src/tokens). To use the default implementation you should include the packages into your *Cargo.toml* file: ```toml -gear-lib = { git = "https://github.com/gear-foundation/dapps-gear-lib.git" } -gear-lib-derive = { git = "https://github.com/gear-foundation/dapps-gear-lib.git" } +gear-lib = { git = "https://github.com/gear-foundation/dapps", tag = "0.3.3" } hashbrown = "0.13.1" ``` @@ -336,7 +335,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `IoNFT` state. For example - [gear-foundation/dapps-non-fungible-token/state](https://github.com/gear-foundation/dapps-non-fungible-token/tree/master/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 `IoNFT` state. For example - [non-fungible-token/state](https://github.com/gear-foundation/dapps/tree/master/contracts/non-fungible-token/state): ```rust #[metawasm] @@ -373,6 +372,10 @@ pub trait Metawasm { ``` ## Conclusion -Gear provides a reusable [library](https://github.com/gear-foundation/dapps-gear-lib/tree/master/lib/src/non_fungible_token) with core functionality for the gNFT protocol. By using object composition, that library can be utilized within a custom NFT contract implementation in order to minimize duplication of community available code. +An NFT smart contract source code is available on [Github](https://github.com/gear-foundation/dapps/tree/master/contracts/non-fungible-token). + +The React frontend application can be downloaded [here](https://github.com/gear-foundation/dapps/tree/master/frontend/non-fungible-token). + +Gear provides a reusable [library](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib/src/tokens) with core functionality for the gNFT protocol. By using object composition, that library can be utilized within a custom NFT contract implementation in order to minimize duplication of community available code. For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing). diff --git a/docs/examples/monopoly.md b/docs/examples/monopoly.md index e32babf61..f0c330f61 100644 --- a/docs/examples/monopoly.md +++ b/docs/examples/monopoly.md @@ -23,9 +23,9 @@ To launch the game, you need to: ## ⚒️ Build Master and Player contracts -- Get the source code of [Master contract](https://github.com/gear-foundation/dapps-syndote/tree/master/syndote) and [Player contract](https://github.com/gear-foundation/dapps-syndote/tree/master/player). +- Get the source code of Master and Player contracts from [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/syndote). - Modify Player's contract as you wish to achieve optimal game strategy. -- Build contracts as described in [program/README.md](https://github.com/gear-foundation/dapps-syndote). +- Build contracts as described in [program/README.md](https://github.com/gear-foundation/dapps/blob/master/contracts/syndote/README.md). ## 🏗️ Upload contracts on chain @@ -34,6 +34,7 @@ There are two ways to upload the game onto the chain: 2. Using [`gear-js/cli`](https://github.com/gear-tech/gear-js/tree/main/tools/cli). ### 1. Using Gear IDEA portal: + - In the network selector select the network where you are going to run the game: - Staging Testnet - wss://rpc-node.gear-tech.io network; - Workshop node - wss://node-workshop.gear.rs; @@ -49,7 +50,7 @@ There are two ways to upload the game onto the chain: ### 2. Using [`gear-js/cli`](https://github.com/gear-tech/gear-js/tree/main/tools/cli) It allows sending transactions to the Gear node based on `yaml` file: -- Go to folder with [scripts](https://github.com/gear-foundation/dapps-syndote/tree/master/upload-game): +- Go to folder with [scripts](https://github.com/gear-foundation/dapps/tree/master/frontend/syndote/upload-game): ``` cd ./upload-game/ ``` @@ -111,7 +112,7 @@ It allows sending transactions to the Gear node based on `yaml` file: ## 🖥️ Build and run user interface -1. Download [this repository](https://github.com/gear-foundation/dapps-syndote) locally and go to the `frontend` folder. +1. Download [this repository](https://github.com/gear-foundation/dapps/tree/master/frontend/syndote) locally and go to the `frontend` folder. 2. Install packages: ```sh yarn install @@ -145,7 +146,8 @@ yarn start ## Smart contracts ### Master contract -[Master contract](https://github.com/gear-foundation/dapps-syndote/tree/master/syndote) is initialized with monopoly card information (cell cost, special cells: jail, lottery). As was already mentioned, it is given enough gas reservation for automatic play. Before each player's step `Master` contract checks the amount of gas and if it is not enough it will send a message to the game admin to request for another gas reservation. +[Master contract](https://github.com/gear-foundation/dapps/tree/master/contracts/syndote/src) is initialized with monopoly card information (cell cost, special cells: jail, lottery). As was already mentioned, it is given enough gas reservation for automatic play. Before each player's step `Master` contract checks the amount of gas and if it is not enough it will send a message to the game admin to request for another gas reservation. + **Players registration**: Players deploy their strategic contracts and send a message `Register` to `Master` contract. Master contract: - Adds the players the list of participants and initializes it with the following structure: @@ -171,7 +173,7 @@ When the required number of participants is reached, the admin sends a message ` ![img alt](./img/monopoly_play.png) **Strategic messages:** -[Strategic contracts](https://github.com/gear-foundation/dapps-syndote/tree/master/player) send strategic messages depending on the position on the monopoly field. A player may be in one of the following positions: +[Strategic contracts](https://github.com/gear-foundation/dapps/tree/master/contracts/syndote/player) send strategic messages depending on the position on the monopoly field. A player may be in one of the following positions: - A cell with his own property. A player has a right: - To add a gear on the cell. The gear can be `Bronze`, `Silver` or `Gold`; - To upgrade a gear (from `Bronze` to `Silver` and from `Silver` to `Gold`); diff --git a/docs/examples/multisig-wallet.md b/docs/examples/multisig-wallet.md index a374e637b..29109659b 100644 --- a/docs/examples/multisig-wallet.md +++ b/docs/examples/multisig-wallet.md @@ -6,13 +6,13 @@ sidebar_position: 13 # Multisig Wallet ## Introduction -Multisignature wallets are cryptocurrency wallets that require one or more private keys to sign and send a transaction. +Multisignature wallets are cryptocurrency wallets that require one or more private keys to sign and authorize a transaction. -Imagine a bank vault that requires more than one key to open: That’s a little how multisignature cryptocurrency wallets work. +To illustrate, think of a bank vault that demands multiple keys to unlock; this analogy captures the essence of how multisignature cryptocurrency wallets operate. -Multisignature proponents argue that multisignature is the most secure and fail-proof way to store cryptocurrency. Even if a thief gets his hands on one of your wallets, for example, they still won’t be able to access your account without the keys to the other wallets in the setup. +Advocates of multisignature wallets argue that they offer the most secure and fail-proof method for storing cryptocurrency. Even if a thief were to obtain one of your wallet keys, they would still be unable to access your account without the keys associated with the other wallets in the setup. -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-multisig-wallet). +This article provides an explanation of the programming interface, data structure, basic functions, and their respective purposes. It can be used as-is or customized to fit your specific needs. Anyone can easily create their own application and deploy it on the Gear Network. The source code is accessible on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/multisig-wallet). ## Logic @@ -146,7 +146,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `State` struct. For example - [gear-foundation/dapps-multisig-wallet/state](https://github.com/gear-foundation/dapps-multisig-wallet/tree/master/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 `State` struct. For example - [gear-foundation/dapps-multisig-wallet/state](https://github.com/gear-foundation/dapps/tree/master/contracts/multisig-wallet/state): ```rust #[metawasm] @@ -271,8 +271,8 @@ pub enum StateReply { ## Source code -The source code of this example of Multisig Wallet smart contract and the example of an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps-multisig-wallet). +The source code of this example of Multisig Wallet smart contract and the example of an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/multisig-wallet). -See also an example of the smart contract testing implementation based on `gtest`: [multisig-wallet/tests](https://github.com/gear-foundation/dapps-multisig-wallet/tree/master/tests). +See also an example of the smart contract testing implementation based on `gtest`: [multisig-wallet/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/multisig-wallet/tests). For more details about testing smart contracts written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article. diff --git a/docs/examples/nft-marketplace/marketplace.md b/docs/examples/nft-marketplace/marketplace.md index d064e9ff4..0cbc8da78 100644 --- a/docs/examples/nft-marketplace/marketplace.md +++ b/docs/examples/nft-marketplace/marketplace.md @@ -7,21 +7,21 @@ sidebar_position: 1 ![img alt](./../img/nft-marketplace.png) -NFT marketplace is a contract where you can buy and sell non-fungible tokens for fungible tokens. The contract also supports holding the NFT auctions and making/accepting purchase offers on NFTs. +NFT marketplace is a smart contract where you can buy and sell non-fungible tokens for fungible tokens. The contract also supports holding the NFT auctions and making/accepting purchase offers on NFTs. -A smart contract examples created by Gear are available on GitHub so anyone can easily create their own NFT marketplace application and run it on the Gear Network: +A smart contract examples are available on GitHub so anyone can easily create their own NFT marketplace application and run it on the Gear-powered network: -- [Gear Non-Fungible Token](https://github.com/gear-foundation/dapps-non-fungible-token/). -- [NFT marketplace](https://github.com/gear-foundation/dapps-nft-marketplace). +- [Gear Non-Fungible Token](https://github.com/gear-foundation/dapps/tree/master/contracts/non-fungible-token). +- [NFT marketplace](https://github.com/gear-foundation/dapps/tree/master/contracts/nft-marketplace). -- Marketplace UI available on [Github](https://github.com/gear-foundation/dapps-nft-marketplace/tree/master/frontend) +- Marketplace UI available on [Github](https://github.com/gear-foundation/dapps/tree/master/frontend/nft-marketplace/frontend) ## How to run ### ⚒️ Build programs -- Build [NFT contract](https://github.com/gear-foundation/dapps-non-fungible-token/) as described in `README.md` -- Build [Marketplace contract](https://github.com/gear-foundation/dapps-nft-marketplace/) as described in `README.md` +- Build [NFT contract](https://github.com/gear-foundation/dapps/tree/master/contracts/non-fungible-token) as described in `README.md` +- Build [Marketplace contract](https://github.com/gear-foundation/dapps/tree/master/contracts/nft-marketplace) as described in `README.md` ### 🏗️ Upload programs @@ -66,7 +66,7 @@ yarn install 2. Configure .evn file. Specify network address and program ID like in the example below: -For proper application functioning, one needs to adjust an environment variable parameters. An example is available [here](https://github.com/gear-tech/gear-js/blob/master/apps/marketplace/.env.example). +For proper application functioning, one needs to adjust an environment variable parameters. An example is available [here](https://github.com/gear-foundation/dapps/blob/master/frontend/nft-marketplace/frontend/.env.example). ```sh REACT_APP_NODE_ADDRESS=wss://rpc-node.gear-tech.io:443 @@ -76,7 +76,7 @@ REACT_APP_MARKETPLACE_CONTRACT_ADDRESS=0xf8e5add537887643f8aa1ee887754d9b2d8c20d REACT_APP_NFT_CONTRACT_ADDRESS=0xa7874ff27e9bac10bf7fd43f4908bb1e273018e15325c16fb35c71966c0c4033 ``` -- `REACT_APP_NODE_ADDRESS` is Gear Network address (wss://rpc-node.gear-tech.io:443) +- `REACT_APP_NODE_ADDRESS` is Gear Network address (wss://testnet.vara.rs) - `REACT_APP_IPFS_ADDRESS` is address of IPFS to store NFT assets (https://ipfs.gear-tech.io/api/v0 was used for Gear Marketplace implementation) - `REACT_APP_IPFS_GATEWAY_ADDRESS` is IPFS Gateway address (https://ipfs-gw.gear-tech.io/ipfs) - `REACT_APP_MARKETPLACE_CONTRACT_ADDRESS` is NFT Marketplace contract address in Gear Network @@ -422,7 +422,7 @@ extern "C" fn 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 `Market` state. For example - [gear-foundation/dapps-nft-marketplace/state](https://github.com/gear-foundation/dapps-nft-marketplace/tree/master/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 `Market` state. For example - [gear-foundation/dapps-nft-marketplace/state](https://github.com/gear-foundation/dapps/tree/master/contracts/nft-marketplace/state): ```rust #[metawasm] diff --git a/docs/examples/nft-marketplace/nft-application.md b/docs/examples/nft-marketplace/nft-application.md index ed99cb5d5..119a9b42e 100644 --- a/docs/examples/nft-marketplace/nft-application.md +++ b/docs/examples/nft-marketplace/nft-application.md @@ -9,11 +9,11 @@ This article explains how to create a `React` application and connect it to an [ ### Preparation -1. First clone the [frontend-starter](https://github.com/LouiseMedova/gear-app-starter). Install [NodeJs](https://nodejs.org/en/download/) and [NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm). Make sure you have the latest LTS version of the NodeJs installed. +1. First clone the [frontend-starter](https://github.com/gear-foundation/dapps/tree/master/frontend/nft-app-starter). Install [NodeJs](https://nodejs.org/en/download/) and [NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm). Make sure you have the latest LTS version of the NodeJs installed. 2. Then install yarn: ```shell - npm install --global yarn + yarn install ``` 3. There is an `.env.example` file. Create your own `.env` file and copy the contents of `.env.example` to your `.env` file. It contains the following variables: @@ -23,11 +23,7 @@ This article explains how to create a `React` application and connect it to an [ 4. Upload the contract to the chain and set up the address in the `.env` file. Place the `meta.txt` file in the `assets/meta` folder and the `nft_state.meta.wasm` file in the `assets/wasm folder`. -5. Install packages: - ```shell - yarn install - ``` - and run the application: +5. Run the application: ```shell yarn start ``` diff --git a/docs/examples/nft-pixelboard.md b/docs/examples/nft-pixelboard.md index aef6ce6cc..972d2e9fe 100644 --- a/docs/examples/nft-pixelboard.md +++ b/docs/examples/nft-pixelboard.md @@ -187,6 +187,6 @@ pub enum NFTPixelboardAction { ## Source code -The source code of the NFT pixelboard smart contract and an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps-nft-pixelboard). They can be used as is or modified to suit your own scenarios. +The source code of the NFT pixelboard smart contract and an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/nft-pixelboard). 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. diff --git a/docs/examples/onchain-nft.md b/docs/examples/onchain-nft.md index 7418d378a..854881592 100644 --- a/docs/examples/onchain-nft.md +++ b/docs/examples/onchain-nft.md @@ -7,13 +7,13 @@ sidebar_position: 17 ## Introduction -This NFT smart-contract example demonstrates an approach when the token assets are stored directly on chain. For details related to common gNFT smart-contract implentation, read: [gNFT-721](https://wiki.gear-tech.io/examples/gnft-721). +This NFT smart-contract example demonstrates an approach when the token assets are stored directly on chain. For details related to common gNFT smart-contract implentation, read: [gNFT-721](gnft-721). When the owner of a given token ID wishes to transfer it to another user, it is easy to verify ownership and reassign the token to a new owner. Mostly NFTs images (or other base resources) are stored somewhere else (e.g. IPFS) and only the metadata is stored in the contract. Metadata consists of a name, an ID and links to the external resources, where the images are actually stored. But there is another approach introduced here. Sometimes you can store NFTs directly on chain without any external storage. This approach helps you not to lose your NFT if there is a problem with the external storage. -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. The source code is available on [GitHub](https://github.com/gear-foundation/dapps-on-chain-nft). +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. The source code is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/on-chain-nft). ## Approach To successfully implement this approach several things are needed. Firstly, when initializing a collection, one should provide all the possible images of all the layers for a collection. Secondly, when minting alongside with a small metadata, one should provide a combination of layers used for a specific NFT. This approach seems quite costly when initializing, but is relatively cheap when it comes to minting. @@ -25,13 +25,12 @@ The functions that must be supported by each non-fungible-token contract: - *mint(to, token_id, metadata)* is a function that creates a new token. Metadata can include any information about the token: it can be a link to a specific resource, a description of the token, etc; - *burn(from, token_id)* is a function that removes the token with the mentioned *token_id* from the contract. -The default implementation of the NFT contract is provided in the gear library: [gear-lib/non_fungible_token](https://github.com/gear-foundation/dapps-gear-lib/tree/master/src/non_fungible_token). +The default implementation of the NFT contract is provided in the gear library: [gear-lib/non_fungible_token](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib/src/tokens). To use the default implementation you should include the packages into your *Cargo.toml* file: ```toml -gear-lib = { git = "https://github.com/gear-foundation/dapps-gear-lib.git" } -gear-lib-derive = { git = "https://github.com/gear-foundation/dapps-gear-lib.git" } +gear-lib = { git = "https://github.com/gear-foundation/dapps", tag = "0.3.3" } hashbrown = "0.13.1" ``` @@ -274,7 +273,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `State` state. For example - [gear-foundation/dapps-on-chain-nft/state](https://github.com/gear-foundation/dapps-on-chain-nft/tree/master/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 `State` state. For example - [gear-foundation/dapps-on-chain-nft/state](https://github.com/gear-foundation/dapps/tree/master/contracts/on-chain-nft/state): ```rust @@ -344,10 +343,10 @@ pub trait Metawasm { ## Conclusion -Gear provides a reusable [library](https://github.com/gear-foundation/dapps-gear-lib/tree/master/lib/src/non_fungible_token) with core functionality for the gNFT protocol. By using object composition, that library can be utilized within a custom NFT contract implementation in order to minimize duplication of community available code. +Gear provides a reusable [library](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib/src) with core functionality for the gNFT protocol. By using object composition, that library can be utilized within a custom NFT contract implementation in order to minimize duplication of community available code. -A source code of the on-chain NFT provided by Gear is available on GitHub: [on-chain-nft/src](https://github.com/gear-foundation/dapps-on-chain-nft). +A source code of the on-chain NFT example is available on GitHub: [on-chain-nft](https://github.com/gear-foundation/dapps/tree/master/contracts/on-chain-nft). -See also an example of the smart contract testing implementation based on `gtest`: [on-chain-nft/tests](https://github.com/gear-foundation/dapps-on-chain-nft/tree/master/tests). +See also an example of the smart contract testing implementation based on `gtest`: [on-chain-nft/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/on-chain-nft/tests). For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing). diff --git a/docs/examples/oracle/dia-randomness-oracle.md b/docs/examples/oracle/dia-randomness-oracle.md index b852cc41b..2ddd5f66f 100644 --- a/docs/examples/oracle/dia-randomness-oracle.md +++ b/docs/examples/oracle/dia-randomness-oracle.md @@ -78,7 +78,7 @@ pub struct InitConfig { ## Conclusion -A source code of the contract example provided by Gear is available on GitHub: [oracle/randomness-oracle/src/lib.rs](https://github.com/gear-foundation/dapps-oracle/blob/wip/randomness-oracle/src/lib.rs). +A source code of the contract example is available on GitHub: [oracle/randomness-oracle/src/lib.rs](https://github.com/gear-foundation/dapps-oracle/blob/wip/randomness-oracle/src/lib.rs). See also an example of the smart contract testing implementation based on `gtest`: [oracle/randomness-oracle/tests/randomness_oracle.rs](https://github.com/gear-foundation/dapps-oracle/blob/wip/randomness-oracle/tests/randomness_oracle.rs). diff --git a/docs/examples/ping.md b/docs/examples/ping.md index 7330faa1e..76cd6472c 100644 --- a/docs/examples/ping.md +++ b/docs/examples/ping.md @@ -7,31 +7,9 @@ sidebar_position: 2 Gear is very easy to write code for! -Let's look at the [minimal program](https://github.com/gear-foundation/dapps-app/). It contains the following files: -``` -. -├── io / -│ ├── src / -│ │ └── lib.rs -│ └── Cargo.toml -├── src/ -│ ├── contract.rs -│ └── lib.rs -├── state/ -│ ├── src/ -│ │ ├── lib.rs -│ │ └── state.rs -│ ├── Cargo.toml -│ └── build.rs -├── tests/ -│ ├── gclient_test.rs -│ └── test.rs -├── Cargo.toml -├── Makefile -├── meta.txt -└── build.rs -``` -The code of the program is in the `src/contract.rs` file. The program replies with `Pong` string if the sender sent `Ping` message to it. It also saves how many times a user sent a ping message to the program. +Let's look at the [minimal program](https://github.com/gear-foundation/dapps/tree/master/contracts/ping). + +The code of the program is in the `src/lib.rs` file. The program replies with `Pong` string if the sender sent `Ping` message to it. It also saves how many times a user sent a ping message to the program. So, the program contains: - state definition: ```rust diff --git a/docs/examples/prerequisites.mdx b/docs/examples/prerequisites.mdx index d0d1a3639..d2b242e2b 100644 --- a/docs/examples/prerequisites.mdx +++ b/docs/examples/prerequisites.mdx @@ -70,12 +70,12 @@ Gear Rust libraries: `gstd`, `gtest`, `gmeta`, `gclient`, `gear-wasm-builder` -commit hash: `946ac47` +v0.3.3 -Make sure the correct commit hash version is specified in the `Cargo.toml` file of the smart contract you're working on. For example: -https://github.com/gear-foundation/dapps-app/blob/master/Cargo.toml#L10 +Make sure the correct version is tagged in the `Cargo.toml` file of the smart contract you're working on. For example: +https://github.com/gear-foundation/dapps/blob/master/contracts/Cargo.toml diff --git a/docs/examples/rmrk.md b/docs/examples/rmrk.md index c2e0b7083..82180a983 100644 --- a/docs/examples/rmrk.md +++ b/docs/examples/rmrk.md @@ -13,7 +13,7 @@ RMRK legos that are already implemented on Gear: - Multi-resource NFTs: The ability for an NFT to vary its output depending on the context it is being loaded in. -This article explains the programming interface, data structure, basic functions and explains their purpose. The source code is available on [GitHub](https://github.com/gear-foundation/dapps-RMRK). +This article explains the programming interface, data structure, basic functions and explains their purpose. The source code is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/rmrk). ## Logic ### Nesting logic @@ -747,7 +747,6 @@ Unequip { ``` ## Source code -The source code of RMRK implementation and the example of an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps-RMRK). - +The source code of RMRK implementation and the example of an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/rmrk). For more details about testing smart contracts written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article. diff --git a/docs/examples/rock-paper-scissors.md b/docs/examples/rock-paper-scissors.md index 70cd77a8d..4c2ebbdf5 100644 --- a/docs/examples/rock-paper-scissors.md +++ b/docs/examples/rock-paper-scissors.md @@ -12,7 +12,7 @@ A simultaneous, zero-sum game, it has three possible outcomes: a draw, a win or One popular five-weapon expansion is "rock paper scissors Spock lizard", invented by Sam Kass and Karen Bryla, which adds "Spock" and "lizard" to the standard three choices. "Spock" is signified with the Star Trek Vulcan salute, while "lizard" is shown by forming the hand into a sock-puppet-like mouth. Spock smashes scissors and vaporizes rock; he is poisoned by lizard and disproved by paper. Lizard poisons Spock and eats paper; it is crushed by rock and decapitated by scissors. This variant was mentioned in a 2005 article in The Times of London and was later the subject of an episode of the American sitcom The Big Bang Theory in 2008 (as rock-paper-scissors-lizard-Spock). -Anyone can easily create their own decentralized game application and run it on the Gear Network. To do this, we have made a "rock paper scissors Spock lizard" game version for multiple players, in which the winner can be determined in several rounds of tense struggle. The source code is available on [GitHub](https://github.com/gear-foundation/dapps-rock-paper-scissors). 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 decentralized game application and run it on the Gear Network. To do this, we have made a "rock paper scissors Spock lizard" game version for multiple players, in which the winner can be determined in several rounds of tense struggle. The source code is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/rock-paper-scissors). 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. ## Logic @@ -150,7 +150,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `ContractState` state. For example - [gear-foundation/dapps-rock-paper-scissors/state](https://github.com/gear-foundation/dapps-rock-paper-scissors/tree/master/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 `ContractState` state. For example - [rock-paper-scissors/state](https://github.com/gear-foundation/dapps/tree/master/contracts/rock-paper-scissors/state): ```rust @@ -178,6 +178,6 @@ pub trait Metawasm { ## Source code -The source code of Rock Paper Scissors implementation and the example of an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps-rock-paper-scissors). +The source code of Rock Paper Scissors implementation and the example of an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/rock-paper-scissors). For more details about testing smart contracts written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article. diff --git a/docs/examples/staking.md b/docs/examples/staking.md index 91ca0edbf..db9d70824 100644 --- a/docs/examples/staking.md +++ b/docs/examples/staking.md @@ -9,7 +9,7 @@ sidebar_position: 18 Stacking is an analogue of a bank deposit, receiving passive earnings due to simple storage of cryptomonets. The percentage of income may be different – it all depends on the term of the deposit. -Anyone can create their own Staking contract and run it on the Gear Network. To do this, Gear created an example which is available on [GitHub](https://github.com/gear-foundation/dapps-staking). +Anyone can create their own Staking contract and run it on the Gear Network. To do this, Gear created an example which is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/staking). 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. @@ -362,7 +362,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `IoStaking` state. For example - [gear-foundation/dapps-staking/state](https://github.com/gear-foundation/dapps-staking/tree/master/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 `IoStaking` state. For example - [staking/state](https://github.com/gear-foundation/dapps/tree/master/contracts/staking/state): ```rust #[metawasm] @@ -390,12 +390,12 @@ The `Staking` contract interacts with the `fungible` token contract. Each transa ## Conclusion -A source code of the contract example provided by Gear is available on GitHub: [`staking/src/lib.rs`](https://github.com/gear-foundation/dapps-staking/blob/master/src/lib.rs). +A source code of the contract example provided by Gear is available on GitHub: [`staking/src/lib.rs`](https://github.com/gear-foundation/dapps/blob/master/contracts/staking/src/lib.rs). See also examples of the smart contract testing implementation based on gtest: -- [`simple_test.rs`](https://github.com/gear-foundation/dapps-staking/blob/master/tests/simple_test.rs). +- [`simple_test.rs`](https://github.com/gear-foundation/dapps/blob/master/contracts/staking/tests/simple_test.rs). -- [`panic_test.rs`](https://github.com/gear-foundation/dapps-staking/blob/master/tests/panic_test.rs). +- [`panic_test.rs`](https://github.com/gear-foundation/dapps/blob/master/contracts/staking/tests/panic_test.rs). For more details about testing smart contracts written on Gear, refer to this article: [Program testing](/docs/developing-contracts/testing). diff --git a/docs/examples/supply-chain.md b/docs/examples/supply-chain.md index 6b0fdbc8b..53787ef50 100644 --- a/docs/examples/supply-chain.md +++ b/docs/examples/supply-chain.md @@ -6,8 +6,8 @@ sidebar_position: 12 In logistics, a supply chain is a system for tracking and delivering to an end consumer various items. As a rule, such systems can't work without a lot of paperwork and other layers of bureaucracy. All of this costs a lot of time and money and increases the likelihood of an accidental error or, worst of all, a fraud. With the help of smart contract and blockchain technologies, it is possible to eliminate these problems by making a supply chain more efficient, reliable and transparent. -- [Supply chain contract](https://github.com/gear-foundation/dapps-supply-chain). -- [Supply chain UI](https://github.com/gear-foundation/dapps-supply-chain/tree/master/frontend). +- [Supply chain contract](https://github.com/gear-foundation/dapps/tree/master/contracts/supply-chain). +- [Supply chain UI](https://github.com/gear-foundation/dapps/tree/master/frontend/supply-chain). ## How to run @@ -15,13 +15,13 @@ In logistics, a supply chain is a system for tracking and delivering to an end c Upload Supply chain contract requires build two auxiliary contracts: -- Build [NFT contract](https://github.com/gear-foundation/dapps-non-fungible-token/) as described in `README.md` -- Build [Sharded FT contract](https://github.com/gear-foundation/dapps-sharded-fungible-token/) as described in `README.md` -- Build [Supply Chain contract](https://github.com/gear-foundation/dapps-supply-chain) as described in `README.md` +- Build [NFT contract](https://github.com/gear-foundation/dapps/tree/master/contracts/non-fungible-token) as described in `README.md` +- Build [Sharded FT contract](https://github.com/gear-foundation/dapps/tree/master/contracts/sharded-fungible-token) as described in `README.md` +- Build [Supply Chain contract](https://github.com/gear-foundation/dapps/tree/master/contracts/supply-chain) as described in `README.md` ### 🏗️ Upload programs -You can deploy a program using [idea.gear-tech.io](https://idea.gear-tech.io/). In the network selector choose `Staging Testnet` or `Development` (in this case, you should have a local node running). +You can deploy a program using [idea.gear-tech.io](https://idea.gear-tech.io/). In the network selector choose `Vara Stable Testnet` or `Development` (in this case, you should have a local node running). *** Non-Fungible Token *** @@ -65,7 +65,7 @@ yarn install 2. Configure .evn file. Specify network address and program ID like in the example below: -For proper application functioning, one needs to adjust an environment variable parameters. An example is available [here](https://github.com/gear-foundation/dapps-supply-chain/blob/master/frontend/.env.example). +For proper application functioning, one needs to adjust an environment variable parameters. An example is available [here](https://github.com/gear-foundation/dapps/blob/master/frontend/supply-chain/.env.example). ```sh REACT_APP_NODE_ADDRESS=wss://rpc-node.gear-tech.io @@ -564,7 +564,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `State` struct. For example - [gear-foundation/dapps-supply-chain/state](https://github.com/gear-foundation/dapps-supply-chain/tree/master/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 `State` struct. For example - [supply-chain/state](https://github.com/gear-foundation/dapps/tree/master/contracts/supply-chain/state): ```rust #[metawasm] @@ -607,6 +607,6 @@ pub type ActorIdInnerSupplyChainAction = (ActorId, InnerAction); ## Source code -The source code of this example of a supply chain smart contract and an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps-supply-chain). They can be used as is or modified to suit your own scenarios. +The source code of this example of a supply chain smart contract and an implementation of its testing is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/supply-chain). 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. diff --git a/docs/examples/tequila-train.md b/docs/examples/tequila-train.md index cc296ff59..98a529a58 100644 --- a/docs/examples/tequila-train.md +++ b/docs/examples/tequila-train.md @@ -34,13 +34,13 @@ The aim is to be the first player to get rid of all the dominoes in their hand. ## How to run -Source code can be found in the GitHub: https://github.com/gear-foundation/dapps-tequila-train +Source code can be found in the [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/tequila-train). Clone the repo and enter to the project directory: ```shell -git clone https://github.com/gear-foundation/dapps-tequila-train -cd tequila-train +git clone https://github.com/gear-foundation/dapps +cd contracts/tequila-train ``` ### Build the smart contract @@ -81,7 +81,7 @@ cd tequila-train ### Upload program and meta to the network -1. Go to https://idea.gear-tech.io/ and choose **Workshop** node (`wss://node-workshop.gear.rs`). +1. Go to https://idea.gear-tech.io/ and choose **Vara Stable Testnet** node (`wss://testnet.vara.rs`). 2. Upload the program binary Wasm `contracts/target/wasm32-unknown-unknown/release/tequila_train.opt.wasm` and the meta file `contracts/tequila_train.meta.txt`. @@ -248,4 +248,4 @@ pub enum State { ## Source code -The source code of the Tequila Train Game smart contract is available on [GitHub](https://github.com/gear-foundation/dapps-tequila-train). They can be used as is or modified to suit your own scenarios. +The source code of the Tequila Train Game smart contract is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/tequila-train). They can be used as is or modified to suit your own scenarios. diff --git a/docs/examples/varatube.md b/docs/examples/varatube.md index c5acaf9ac..5ad62599a 100644 --- a/docs/examples/varatube.md +++ b/docs/examples/varatube.md @@ -11,7 +11,7 @@ sidebar_position: 24 Many web services (in Web2) work on a subscription basis. One of the main features of subscription management is subscription auto-renewal. So that after the expiration of the subscription period, the money is automatically debited from the wallet and the subscription is automatically renewed without user intervention. -This dApp example represents a video-hosting service **[VaraTube](https://github.com/gear-foundation/dapps-varatube)** that enables watching videos with a valid subscription that can be renewed automatically. +This dApp example represents a video-hosting service **[VaraTube](https://github.com/gear-foundation/dapps/tree/master/contracts/varatube)** that enables watching videos with a valid subscription that can be renewed automatically. ### Decentralization aspect @@ -23,17 +23,31 @@ This makes it possible to implement logic when several logically related message State consistency between smart contracts is achieved using techniques described [here](/developing-contracts/distributed_transactions.md). +## Program logic + +![img alt](./img/enable-subscription.png) + +When a user purchases a subscription, access to the service is open, and after the subscription expires, access is closed. + +The interface provides an option whether to enable or disable subscription auto-renewal. And if it is enabled, the subscription will be renewed automatically by getting funds from the user's. + +There is also an option to cancel the active subscription. + +The VaraTube consists of two smart contracts: +- [Gear Fungible Token (GFT-20)](gft-20) contract determines user and service balances required to purchase a subscription and approves Subscription contract to get funds from user's balance. +- [VaraTube Subscription](https://github.com/gear-foundation/dapps/tree/master/contracts/varatube) contract manages service's subscription - its availability, expiration, auto renewal. + ## How to run ### ⚒️ Build program -- Get the source code of [VaraTube contract](https://github.com/gear-foundation/dapps-varatube/tree/master/src) and [Fungible Token contract](https://github.com/gear-foundation/dapps-fungible-token) -- Build contracts as described in [program/README.md](https://github.com/gear-foundation/dapps-varatube#readme). +- Get the source code of [VaraTube contract](https://github.com/gear-foundation/dapps/tree/master/contracts/varatube/src) and [Fungible Token contract](https://github.com/gear-foundation/dapps/tree/master/contracts/fungible-token) +- Build contracts as described in [README.md](https://github.com/gear-foundation/dapps/tree/master/contracts/fungible-token#readme). ### 🏗️ Upload program 1. You can deploy a program using [idea.gear-tech.io](https://idea.gear-tech.io/) -2. In the network selector choose `Staging Testnet` or `Development` in case if you have running a local node +2. In the network selector choose `Vara Stable Testnet` or `Development` in case if you have running a local node 3. Upload program `varatube.opt.wasm` from `/target/wasm32-unknown-unknown/release/` 4. Upload metadata file `meta.txt` 5. Specify `init payload` and calculate gas! @@ -41,7 +55,7 @@ State consistency between smart contracts is achieved using techniques described ### 🖥️ Run UI -1. Install packages as described in [frontend/README.md](https://github.com/gear-foundation/dapps-varatube/tree/master/frontend#readme) +1. Download React application repository and install packages as described in [frontend/README.md](https://github.com/gear-foundation/dapps/blob/master/frontend/varatube/README.md) ```sh yarn install @@ -62,22 +76,8 @@ REACT_APP_FT_CONTRACT_ADDRESS=0xa2677f49725647da5cff15e8a42b2ead9102c387d646ff85 yarn start ``` -## Program logic - -![img alt](./img/enable-subscription.png) - -When a user purchases a subscription, access to the service is open, and after the subscription expires, access is closed. - -The interface provides an option whether to enable or disable subscription auto-renewal. And if it is enabled, the subscription will be renewed automatically by getting funds from the user's. - -There is also an option to cancel the active subscription. - -The VaraTube consists of two smart contracts: -- [Gear Fungible Token (GFT-20)](/docs/examples/gft-20) contract determines user and service balances required to purchase a subscription and approves Subscription contract to get funds from user's balance. -- [VaraTube Subscription](https://github.com/gear-foundation/dapps-varatube#readme) contract manages service's subscription - its availability, expiration, auto renewal. - ## Source code -The source code of the VaraTube smart contract including its testing as well as JS frontend web application example is available on [GitHub](https://github.com/gear-foundation/dapps-varatube). They can be used as is or modified to suit your own scenarios. +The source code of the VaraTube smart contract including its testing as well as JS frontend web application example is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/varatube). 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. From cd3520ae61f145b898a4f4a6799ce7587eda1298 Mon Sep 17 00:00:00 2001 From: Shamil <66209982+shamilsan@users.noreply.github.com> Date: Tue, 19 Sep 2023 19:04:38 +0300 Subject: [PATCH 02/18] fix(ci): remove redirect to feeds --- redirectRules.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/redirectRules.js b/redirectRules.js index 755ff6188..3c81868d5 100644 --- a/redirectRules.js +++ b/redirectRules.js @@ -123,10 +123,6 @@ const urlList = [ "to": "/docs/examples/gmt-1155", "from": "/examples/gmt-1155" }, - { - "to": "/docs/examples/feeds", - "from": "/examples/feeds" - }, { "to": "/docs/examples/DAO", "from": "/examples/DAO" From fbbe467e87b5149342bfd66c4b7d5df4839351bb Mon Sep 17 00:00:00 2001 From: Shamil <66209982+shamilsan@users.noreply.github.com> Date: Tue, 19 Sep 2023 19:07:55 +0300 Subject: [PATCH 03/18] fix(ci): remove redirect to feeds --- redirectRules.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/redirectRules.js b/redirectRules.js index 3c81868d5..f51b4e332 100644 --- a/redirectRules.js +++ b/redirectRules.js @@ -283,10 +283,6 @@ const urlList = [ "to": "/docs/examples/gmt-1155", "from": "/gmt-1155" }, - { - "to": "/docs/examples/feeds", - "from": "/feeds" - }, { "to": "/docs/examples/DAO", "from": "/DAO" From 686a6d91d5f39243c60eb4d221cab2ab81c5eb41 Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:13:58 +0300 Subject: [PATCH 04/18] Update docs/examples/DAO.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/DAO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/DAO.md b/docs/examples/DAO.md index 8e026c61f..f52aee9c5 100644 --- a/docs/examples/DAO.md +++ b/docs/examples/DAO.md @@ -301,7 +301,7 @@ extern "C" fn state() { .expect("Failed to share 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 `DaoState` state. For example - [gear-foundation/dapps-dao/state](https://github.com/gear-foundation/dapps/tree/master/contracts/dao/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 `DaoState` state. For example - [gear-foundation/dapps/dao/state](https://github.com/gear-foundation/dapps/tree/master/contracts/dao/state): ```rust #[metawasm] From ea774272daeab35e02ab9bc61ab48e1d51c25d62 Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:14:13 +0300 Subject: [PATCH 05/18] Update docs/examples/crowdsale.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/crowdsale.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/crowdsale.md b/docs/examples/crowdsale.md index 746d80735..ff3cb9cfa 100644 --- a/docs/examples/crowdsale.md +++ b/docs/examples/crowdsale.md @@ -174,7 +174,7 @@ extern "C" fn 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 `State` state. For example - [gear-foundation/dapps-crowdsale/state](https://github.com/gear-foundation/dapps/tree/master/contracts/crowdsale/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 `State` state. For example - [gear-foundation/dapps/crowdsale/state](https://github.com/gear-foundation/dapps/tree/master/contracts/crowdsale/state): ```rust #[metawasm] From 8da6e8a50126b0df5fed650ae2d5ec6dae2c1bc6 Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:14:34 +0300 Subject: [PATCH 06/18] Update docs/examples/dein.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/dein.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/dein.md b/docs/examples/dein.md index 386b95d95..8c0f82273 100644 --- a/docs/examples/dein.md +++ b/docs/examples/dein.md @@ -12,7 +12,7 @@ Briefly the solution consists of a DNS program that is uploaded on-chain. It lis The source code of the smart contract and frontend implementation is available on [GitHub](https://github.com/gear-foundation/dapps/tree/master/contracts/ddns). Note that its repository contains a git submodule, so cloning should be done with the `--recurse-submodules` flag, i.e.: ``` -git clone --recurse-submodules "https://github.com/gear-foundation/dapps/tree/master/contracts/ddns" +git clone --recurse-submodules "https://github.com/gear-foundation/dapps" ``` ## Connect your dApp to the Decentralized Internet From e5ce66545f0fdd27ff29df2b0ba192a576fdbcca Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:15:49 +0300 Subject: [PATCH 07/18] Update docs/examples/dex.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/dex.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/dex.md b/docs/examples/dex.md index cad832d35..2f16744f3 100644 --- a/docs/examples/dex.md +++ b/docs/examples/dex.md @@ -19,7 +19,7 @@ The exchange uses [Gear fungible tokens (GFT-20)](gft-20) underneath for the tok ### Math As it was said all the prices are algorithmically calculated. Investors provide funds to the liquidity pools and price is calculated according to the amount of tokens in the reserves using the following formula:

$$reserve0 * reserve1 = K$$, where $$reserve0, reserve1$$ - are the reserves of token0 and token1 respectively provided by the investors, and $$K$$ - is the constant. -All the prices/amounts all calculated in the way that the $$K$$ MUST remain constant. This basically means that the more token0 we have in pool, the lower price of token1 will be when performing a swap. +All the prices/amounts are calculated in the way that the $$K$$ **MUST** remain constant. This basically means that the more token0 we have in the pool, the lower price of token1 will be when performing a swap. ## Factory contract description Taking into account that we might have a large amount of trading pairs, we should have a way to monitor them/deploy another one and etc. That's where a factory comes into play. Factory helps to create a new pair and monitor all the existing pairs. From 712d9fc24eb20341a8b4d2f0ea3128554f2b23ae Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:16:01 +0300 Subject: [PATCH 08/18] Update docs/examples/dynamic-nft.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/dynamic-nft.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/dynamic-nft.md b/docs/examples/dynamic-nft.md index 6f5422dec..51c7582a8 100644 --- a/docs/examples/dynamic-nft.md +++ b/docs/examples/dynamic-nft.md @@ -193,6 +193,6 @@ Gear provides a reusable [library](https://github.com/gear-foundation/dapps/blob A source code of the Gear NFT smart contract example based on `gear-lib` is available on GitHub: [gear-foundation/dapps-non-fungible-token](https://github.com/gear-foundation/dapps/tree/master/contracts/dynamic-nft). -See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-non-fungible-token/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/dynamic-nft/tests). +See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps/non-fungible-token/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/dynamic-nft/tests). For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing). From eeb4f36b4d55bb31783580f945ebd48c0e946cc0 Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:16:23 +0300 Subject: [PATCH 09/18] Update docs/examples/gnft-4907.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/gnft-4907.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/gnft-4907.md b/docs/examples/gnft-4907.md index 037bd462c..73c47ee46 100644 --- a/docs/examples/gnft-4907.md +++ b/docs/examples/gnft-4907.md @@ -88,6 +88,6 @@ Gear provides a reusable [library](https://github.com/gear-foundation/dapps/tree A source code of the Gear NFT smart contract example based on `gear-lib` is available on GitHub: [gear-foundation/dapps-non-fungible-token](https://github.com/gear-foundation/dapps/tree/master/contracts/rentable-nft). -See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-non-fungible-token/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/rentable-nft/tests). +See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps/non-fungible-token/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/rentable-nft/tests). For more details about testing smart contracts written on Gear, refer to this article: [Program Testing](/docs/developing-contracts/testing). From d2a3a238bd5d5f37a0070be208334320a2d8188e Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:16:38 +0300 Subject: [PATCH 10/18] Update docs/examples/multisig-wallet.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/multisig-wallet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/multisig-wallet.md b/docs/examples/multisig-wallet.md index 29109659b..2e7f7b183 100644 --- a/docs/examples/multisig-wallet.md +++ b/docs/examples/multisig-wallet.md @@ -146,7 +146,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `State` struct. For example - [gear-foundation/dapps-multisig-wallet/state](https://github.com/gear-foundation/dapps/tree/master/contracts/multisig-wallet/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 `State` struct. For example - [gear-foundation/dapps/multisig-wallet/state](https://github.com/gear-foundation/dapps/tree/master/contracts/multisig-wallet/state): ```rust #[metawasm] From 7a3a593def2bbdcaa437bc53db54f681f05bcd8b Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:16:51 +0300 Subject: [PATCH 11/18] Update docs/examples/onchain-nft.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/onchain-nft.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/onchain-nft.md b/docs/examples/onchain-nft.md index 854881592..186e31115 100644 --- a/docs/examples/onchain-nft.md +++ b/docs/examples/onchain-nft.md @@ -273,7 +273,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `State` state. For example - [gear-foundation/dapps-on-chain-nft/state](https://github.com/gear-foundation/dapps/tree/master/contracts/on-chain-nft/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 `State` state. For example - [gear-foundation/dapps/on-chain-nft/state](https://github.com/gear-foundation/dapps/tree/master/contracts/on-chain-nft/state): ```rust From 79a77c9c300664ae6443e12cecd1fda770ae99a1 Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:17:36 +0300 Subject: [PATCH 12/18] Update docs/examples/dex.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/dex.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/dex.md b/docs/examples/dex.md index 2f16744f3..77f70e048 100644 --- a/docs/examples/dex.md +++ b/docs/examples/dex.md @@ -130,7 +130,7 @@ extern "C" fn state() { .expect("Failed to encode or reply with `::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 `State` struct. For example - [gear-foundation/dapps-dex/factory/state](https://github.com/gear-foundation/dapps-dex/tree/master/factory/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 `State` struct. For example - [gear-foundation/dapps/dex/factory/state](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/factory/state): ```rust #[metawasm] From fc25075e72cc67bf63675a5f78c7216d111590fc Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:17:50 +0300 Subject: [PATCH 13/18] Update docs/examples/dex.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/dex.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/dex.md b/docs/examples/dex.md index 77f70e048..605e25209 100644 --- a/docs/examples/dex.md +++ b/docs/examples/dex.md @@ -188,7 +188,7 @@ async fn create_pair(&mut self, mut token_a: ActorId, mut token_b: ActorId); ``` ### Source code -The source code of this example of DEX factory smart contract and the example of an implementation of its testing is available on [gear-foundation/dapps-dex/tree/master/factory](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/factory). +The source code of this example of DEX factory smart contract and the example of an implementation of its testing is available on [gear-foundation/dapps/dex/factory](https://github.com/gear-foundation/dapps/tree/master/contracts/dex/factory). See also an example of the smart contract testing implementation based on `gtest`: [tests/utils/factory.rs](https://github.com/gear-foundation/dapps/blob/master/contracts/dex/tests/utils/factory.rs). From edd4708756454949a268cdc55212ca35df25b198 Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:18:25 +0300 Subject: [PATCH 14/18] Update docs/examples/dutch-auction.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/dutch-auction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/dutch-auction.md b/docs/examples/dutch-auction.md index ead47ad13..48367fb72 100644 --- a/docs/examples/dutch-auction.md +++ b/docs/examples/dutch-auction.md @@ -138,6 +138,6 @@ pub mod metafns { The source code of this example of Dutch Auction smart contract and the example of an implementation of its testing is available on [gear-foundation/dapps-dutch-auction](https://github.com/gear-foundation/dapps/tree/master/contracts/dutch-auction). -See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps-dutch-auction/tree/master/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/dutch-auction/tests). +See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps/dutch-auction/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/dutch-auction/tests). For more details about testing smart contracts written on Gear, refer to the [Program Testing](/docs/developing-contracts/testing) article. From 5874d51ce3666583fabecd05dc3b93e4863d825a Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:19:04 +0300 Subject: [PATCH 15/18] Update docs/examples/dynamic-nft.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/dynamic-nft.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/examples/dynamic-nft.md b/docs/examples/dynamic-nft.md index 51c7582a8..c8b3597d6 100644 --- a/docs/examples/dynamic-nft.md +++ b/docs/examples/dynamic-nft.md @@ -21,8 +21,8 @@ The default implementation of the NFT contract is provided in the Gear library: To use the default implementation you should include the packages into your *Cargo.toml* file: ```toml -gear-lib = { git = "https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib.git" } -gear-lib-derive = { git = "https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib.git" } +gear-lib = { git = "https://github.com/gear-foundation/dapps.git" } +gear-lib-derive = { git = "https://github.com/gear-foundation/dapps.git" } hashbrown = "0.13" ``` From 69184c063d7641b798e4795c1a90833c4f8129c2 Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 17:19:18 +0300 Subject: [PATCH 16/18] Update docs/examples/dynamic-nft.md Co-authored-by: Shamil <66209982+shamilsan@users.noreply.github.com> --- docs/examples/dynamic-nft.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/dynamic-nft.md b/docs/examples/dynamic-nft.md index c8b3597d6..0cafe762a 100644 --- a/docs/examples/dynamic-nft.md +++ b/docs/examples/dynamic-nft.md @@ -191,7 +191,7 @@ Similarly, you can implement other logic, for example, periodically request data Gear provides a reusable [library](https://github.com/gear-foundation/dapps/blob/master/contracts/gear-lib/src/tokens/non_fungible.rs) with core functionality for the `gNFT-4907` protocol. By using object composition, the library can be utilized within a custom NFT contract implementation in order to minimize duplication of community available code. -A source code of the Gear NFT smart contract example based on `gear-lib` is available on GitHub: [gear-foundation/dapps-non-fungible-token](https://github.com/gear-foundation/dapps/tree/master/contracts/dynamic-nft). +A source code of the Gear NFT smart contract example based on `gear-lib` is available on GitHub: [gear-foundation/dapps/non-fungible-token](https://github.com/gear-foundation/dapps/tree/master/contracts/dynamic-nft). See also an example of the smart contract testing implementation based on `gtest`: [gear-foundation/dapps/non-fungible-token/tests](https://github.com/gear-foundation/dapps/tree/master/contracts/dynamic-nft/tests). From 1375a8dded4bbdbfadb3511bcb8fed264a5d1435 Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 18:00:59 +0300 Subject: [PATCH 17/18] Update docs/examples/dex.md Co-authored-by: Fluid <90795031+fluiderson@users.noreply.github.com> --- docs/examples/dex.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/dex.md b/docs/examples/dex.md index 605e25209..b8ba6fe63 100644 --- a/docs/examples/dex.md +++ b/docs/examples/dex.md @@ -14,7 +14,7 @@ While transactions on a centralized exchange are recorded in that exchange's int DEXs are usually built on open-source code, meaning that anyone interested can see exactly how they work. This also means that developers can adapt existing code to create new competing projects, which is how Uniswap's code has been adapted by a whole host of DEXs with "swap" in their names, such as Sushiswap and Pancakeswap. -The exchange uses [Gear fungible tokens (GFT-20)](gft-20) underneath for the tokens and [Gear-lib FT wrapper](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib/src/tokens/fungible) for the pair to keep track of the liquidity. +The exchange uses [Gear fungible tokens (GFT-20)](gft-20) underneath for the tokens and [Gear-lib FT wrapper](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib-old/src/fungible_token) for the pair to keep track of the liquidity. ### Math As it was said all the prices are algorithmically calculated. Investors provide funds to the liquidity pools and price is calculated according to the amount of tokens in the reserves using the following formula:

From f340bf80dfe0a357a3bb634f0275bfb7f6849313 Mon Sep 17 00:00:00 2001 From: AndrePanin Date: Wed, 20 Sep 2023 18:01:13 +0300 Subject: [PATCH 18/18] Update docs/examples/gnft-4907.md Co-authored-by: Fluid <90795031+fluiderson@users.noreply.github.com> --- docs/examples/gnft-4907.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/gnft-4907.md b/docs/examples/gnft-4907.md index 73c47ee46..378e88382 100644 --- a/docs/examples/gnft-4907.md +++ b/docs/examples/gnft-4907.md @@ -19,7 +19,7 @@ Moreover, applications of this model, such as renting, often require that user a ### Details -The default implementation of the NFT contract is provided in the gear library: [gear-lib/non_fungible_token](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib/src/tokens). +The default implementation of the NFT contract is provided in the gear library: [gear-lib/non_fungible_token](https://github.com/gear-foundation/dapps/tree/master/contracts/gear-lib-old/src/non_fungible_token). To use the default implementation you should include the packages into your *Cargo.toml* file: