You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-29Lines changed: 49 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,35 +1,64 @@
1
-
# DigitalMarketplace
1
+
# Digital Marketplace
2
+
3
+
## What does this application do?
4
+
5
+
This app is an online marketplace where people can buy and sell digital items like artwork, music, or software. It works in a simple, secure way that doesn’t require a middleman like a bank or a third payment service provider. Any seller can open their own store, represented by a smart contract, send the assets to be sold and allow users to purchase them paying in Algo.
6
+
7
+
### Actors
8
+
1. <strong>Sellers:</strong> Can list their digital items on the app and set a price and amount to be sold. Once listed, their items are available for buyers to see and purchase. At any time, the seller can close the sales and retrieve the revenue generated from the assets sold.
9
+
2. <strong>Buyers:</strong> can browse the marketplace to find sellers and their stores (each store is a different smart contract). When making a purchase, the payment will be made in ALGO.
10
+
11
+
### How it Works
12
+
When a buyer makes a purchase, the app ensures that the seller receives the payment and the buyer gets access to the item. Thanks to atomic transactions in Algorand, this happens securely and without needing a bank or third party to process the payment.
13
+
14
+
A link to the functional deployed version can be found here: [https://link-to-dapp.com]
1. The Seller creates the store through a Smart contract deployment, this generates an application ID that serves for identify the seller's store for an specific item or Asset.
20
+
2. For receiving the assets to be sold, the smart contract must execute an opt-in to the asset.
21
+
3. Once the smart contract is able to receive the assets, the seller will send the assets to the application's account. By completing this, the store is ready and any users is able to purchase an asset.
22
+
4. A buyer can find a specific store with assets listed and purchase one or more assets, sending a payment transaction to the contract and receiving the asset, in order to be able to receive the asset the buyer must have executed an optín to the asset.
23
+
5. When the total of assets is sold, or at anytime the seller prefers, the seller user can close the sales and the store to retrieve the earnings of the sales and get back all the assets left. With this process the contract will be deleted and the application flow has ended.
24
+
25
+
## Application Architecture
26
+
This application involves the following components:
27
+
- 01 Smart Contract
28
+
- 01 Frontend React Client
29
+
30
+
### Smart Contract Methods
31
+
- create_application
32
+
- Initializes the smart contract with initial parameters such as price and asset ID
33
+
- set_price
34
+
- Modifies the asset sale price
35
+
- opt_in_to_asset
36
+
- Allows the smart contract to receive the asset to be sold
37
+
- buy
38
+
- Performs an asset purchase through an atomic transaction involving the ALGO payment and asset transfer
39
+
- Delete_application
40
+
- Allows the seller to retrieve the ALGO earned by the assets sold and the assets left, deleting the application (closing the store)
41
+
42
+
### Frontend key items
43
+
-`./src/components/MethodCall.tsx` - The component responsible for routing the contract's methods calls.
44
+
-`./src/methods.ts` - This file contains all the logic for executing the system flow calling the smart contract's methods in gropus according to the business logic.
45
+
-`./src/Home.tsx` - The main file containing the backbone of the frontend application.
2
46
3
-
This starter full stack project has been generated using AlgoKit. See below for default getting started instructions.
4
47
5
48
## Setup
6
49
7
50
### Initial setup
8
51
1. Clone this repository to your local machine.
9
52
2. Ensure [Docker](https://www.docker.com/) is installed and operational. Then, install `AlgoKit` following this [guide](https://github.com/algorandfoundation/algokit-cli#install).
10
53
3. Run `algokit project bootstrap all` in the project directory. This command sets up your environment by installing necessary dependencies, setting up a Python virtual environment, and preparing your `.env` file.
11
-
4. In the case of a smart contract project, execute `algokit generate env-file -a target_network localnet` from the `DigitalMarketplace-contracts` directory to create a `.env.localnet` file with default configuration for `localnet`.
12
-
5. To build your project, execute `algokit project run build`. This compiles your project and prepares it for running.
13
-
6. For project-specific instructions, refer to the READMEs of the child projects:
4. To start up the project execute `algokit project run build` in the `projects/DigitalMarketplace-contracts` folder. This compiles your project and prepares its for running. Then execute `npm run dev` into the `projects/DigitalMarketplace-frontend` folder to generate the client linked from the contract start up a local environment for the frontend.
16
55
17
56
> This project is structured as a monorepo, refer to the [documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/project/run.md) to learn more about custom command orchestration via `algokit project run`.
18
57
19
-
### Subsequently
20
-
21
-
1. If you update to the latest source code and there are new dependencies, you will need to run `algokit project bootstrap all` again.
This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) to define CI/CD workflows, which are located in the [`.github/workflows`](./.github/workflows) folder. You can configure these actions to suit your project's needs, including CI checks, audits, linting, type checking, testing, and deployments to TestNet.
27
58
28
-
For pushes to `main` branch, after the above checks pass, the following deployment actions are performed:
29
-
- The smart contract(s) are deployed to TestNet using [AlgoNode](https://algonode.io).
30
-
- The frontend application is deployed to a provider of your choice (Netlify, Vercel, etc.). See [frontend README](frontend/README.md) for more information.
31
-
32
-
> Please note deployment of smart contracts is done via `algokit deploy` command which can be invoked both via CI as seen on this project, or locally. For more information on how to use `algokit deploy` please see [AlgoKit documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/deploy.md).
59
+
### Changing network
60
+
1. In the case of the smart contract, execute `algokit generate env-file -a target_network localnet` from the `DigitalMarketplace-contracts` directory to create a `.env.localnet` file with default configuration for `localnet`.
61
+
2. For changing the network with which the frontend will interact, you need to copy the `.env.template` and create your own `env` following the instructions inside of the file by uncommenting the desired network config. Once you do this, the next time you start up the frontend, you will be interacting with the specified network.
33
62
34
63
## Tools
35
64
@@ -43,13 +72,4 @@ This project makes use of Python and React to build Algorand smart contracts and
43
72
44
73
It has also been configured to have a productive dev experience out of the box in [VS Code](https://code.visualstudio.com/), see the [backend .vscode](./backend/.vscode) and [frontend .vscode](./frontend/.vscode) folders for more details.
45
74
46
-
## Integrating with smart contracts and application clients
47
-
48
-
Refer to the [DigitalMarketplace-contracts](projects/DigitalMarketplace-contracts/README.md) folder for overview of working with smart contracts, [projects/DigitalMarketplace-frontend](projects/DigitalMarketplace-frontend/README.md) for overview of the React project and the [projects/DigitalMarketplace-frontend/contracts](projects/DigitalMarketplace-frontend/src/contracts/README.md) folder for README on adding new smart contracts from backend as application clients on your frontend. The templates provided in these folders will help you get started.
49
-
When you compile and generate smart contract artifacts, your frontend component will automatically generate typescript application clients from smart contract artifacts and move them to `frontend/src/contracts` folder, see [`generate:app-clients` in package.json](projects/DigitalMarketplace-frontend/package.json). Afterwards, you are free to import and use them in your frontend application.
50
-
51
-
The frontend starter also provides an example of interactions with your DigitalMarketplaceClient in [`AppCalls.tsx`](projects/DigitalMarketplace-frontend/src/components/AppCalls.tsx) component by default.
52
-
53
-
## Next Steps
54
75
55
-
You can take this project and customize it to build your own decentralized applications on Algorand. Make sure to understand how to use AlgoKit and how to write smart contracts for Algorand before you start.
0 commit comments