Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Soroban Merge] Dapps Challenge #497

Merged
merged 54 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
3463f57
Add dapps challenge (#487)
Julian-dev28 Jul 26, 2023
22eb062
Update initialization.mdx (#518)
Julian-dev28 Jul 26, 2023
2ec350e
editorial nits for dapps challenge (#544)
briwylde08 Aug 15, 2023
024d259
Add scaffold soroban (#545)
Julian-dev28 Aug 16, 2023
1f7368b
SDC UI upgrades (#542)
Julian-dev28 Aug 16, 2023
d072921
Updated mdx files on dapps (#525)
criadoperez Sep 15, 2023
7c16b60
Add lp dapp challenge (#543)
Julian-dev28 Sep 20, 2023
487d333
Update Futurenet to Testnet Across Documentation (#577)
Julian-dev28 Sep 22, 2023
8d3303f
Soroban Dapps Challenge: Update Sidebar and Remove Local Deployment (…
Julian-dev28 Oct 5, 2023
0364587
Leaderboard and Freighter API integration (#598)
illiassmalashchuk Oct 11, 2023
4ca4a4c
update leaderboard ranking toggle (#609)
Julian-dev28 Oct 11, 2023
dca5075
Corrected calculation of total pages so that 'Prev' and 'Next' button…
MazurakIhor Oct 13, 2023
4c86d7c
Add tabs to dapps challenge checkpoints (#610)
Julian-dev28 Oct 13, 2023
4b1a4fc
feat: provide a means of receiving simple feedback from users (#587)
ElliotFriend Oct 26, 2023
6d1a95c
Remove docker image hashes (#628)
ElliotFriend Oct 26, 2023
f12a08c
Update Soroban Dapps Challenge copy (#631)
Julian-dev28 Nov 1, 2023
b3e642f
Sdc mental models: payment dapp upgrades (#641)
nmadadair Nov 14, 2023
4b91088
Add oracle dapp challenge (#664)
Julian-dev28 Dec 1, 2023
214a207
update title (#665)
Julian-dev28 Dec 1, 2023
a78b151
Liquidity Pool Dapp copy updates v2 (#651)
Julian-dev28 Dec 7, 2023
de7e2c4
Add v20.0.0 (#668)
Julian-dev28 Dec 18, 2023
accd3fb
Update JavaScript SDK references to use the `@stellar/stellar-sdk` pa…
Shaptic Dec 22, 2023
8876229
Pre mainnet restructure (#644)
ElliotFriend Jan 9, 2024
b160ea4
update SDC leaderboard (#712)
Julian-dev28 Jan 31, 2024
768bafe
Refactor wrap/deploy of SAC (#718)
tupui Feb 20, 2024
373f384
Refactor deprecated calls to `soroban config` (#731)
tupui Feb 20, 2024
0ad3165
Update the community RPC list (#744)
janewang Feb 26, 2024
b6a8f4a
Merge remote-tracking branch 'merge-subset/main' into soroban-merge/d…
ElliotFriend Apr 16, 2024
87ac6f9
move dapps challenge directory into place
ElliotFriend Apr 16, 2024
7d045c4
install new packages for dapps-challenge
ElliotFriend Apr 16, 2024
e06b1f6
delete mispelled constants file
ElliotFriend Apr 16, 2024
8c2e077
fix relative imports
ElliotFriend Apr 16, 2024
074b377
move challenges to pages directory, and use README files
ElliotFriend Apr 16, 2024
5d01f02
correct markdown link
ElliotFriend Apr 16, 2024
bde1ff2
fix broken links in dapps challenge docs
ElliotFriend Apr 17, 2024
ea5298e
fix link routes in dapps challenge dashboard
ElliotFriend Apr 17, 2024
30df5fb
add /src/pages dir to markdown formatting checks; format markdown
ElliotFriend Apr 17, 2024
7ad131e
fix relative imports on dapps challenge dashboard
ElliotFriend Apr 17, 2024
047ab82
move the dashboard location into the dapps URLs
ElliotFriend Apr 17, 2024
04a4c9c
add dapps challenge dashboard to the sidebar
ElliotFriend Apr 17, 2024
eb1d95e
remove soroban events provider component from challenge forms
ElliotFriend Apr 17, 2024
f3a62fa
fix dashboard links on dapp challenge pages
ElliotFriend Apr 17, 2024
f76bb86
change some frontmater and remove head items from dapps challenges
ElliotFriend Apr 17, 2024
c001665
move the docker guide from dapps challenge to guides
ElliotFriend Apr 18, 2024
8308f4f
move the rest of the dapps challenge guides
ElliotFriend Apr 18, 2024
55da604
update and move around the dapps guides
ElliotFriend Apr 18, 2024
d5f52f3
lint and format markdown
ElliotFriend Apr 18, 2024
ef51eb5
redirect /dapps requests, just in case
ElliotFriend Apr 18, 2024
6ea9e46
remove link to guide content that no longer exists
ElliotFriend Apr 18, 2024
73c60a0
add link to dapps challenge in footer
ElliotFriend Apr 18, 2024
6affdde
add link to freighter guide on dapps challenge intro page
ElliotFriend Apr 19, 2024
c73b225
Update Dapps Challenge name in sidebar
Julian-dev28 Apr 23, 2024
0d666d5
Merge branch 'main' into soroban-merge/dapps-challenge
ElliotFriend Apr 24, 2024
0df1577
Merge branch 'soroban-merge/dapps-challenge' of github.com:stellar/st…
ElliotFriend Apr 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/learn/interactive/dapps/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Dapps Challenge
sidebar_position: 60
---

import DocCardList from "@theme/DocCardList";

The Soroban Dapps Challenge is a dynamic course designed for developers eager to explore the potential of building decentralized applications (Dapps) on the Soroban smart contracts platform.

<DocCardList />
31 changes: 31 additions & 0 deletions docs/learn/interactive/dapps/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
sidebar_position: 10
title: Dapps on Soroban
sidebar_label: Introduction
---

Decentralized applications, or "dapps," mark a significant shift in our digital interactions, running on a blockchain or peer-to-peer network instead of centralized servers. This shift enhances transparency, security, and user control, as data and smart contracts are stored on a public ledger, open for audit by anyone. Soroban facilitates building and deploying dapps on the Stellar blockchain, offering tools and frameworks that simplify the development process for even those with minimal coding experience. The Soroban Dapps Challenge highlights this, enabling you to create a variety of dapp use cases on a single page in just 20 minutes, with minimal coding, guiding you from smart contract deployment to user interaction through a web frontend.

The Soroban Dapps Challenge is a dynamic course designed for developers eager to explore the potential of building decentralized applications (Dapps) on the Soroban smart contracts platform. This course is part challenge, part educational journey that sets the stage for practical and creative blockchain development.

While the course specifically focuses on the Soroban platform, the knowledge you gain can be applied to other transaction processors such as different blockchains, L2s, and permissioned ledgers. The skills you acquire here are meant to be transferable and versatile.

Through The Soroban Dapps Challenge, you'll have hands-on experience using Soroban's initial versions of the smart contracts environment, a Rust SDK, a CLI, and an RPC server. You'll learn how to write, test, and deploy smart contracts, and you'll get to see your code in action on Futurenet.

## What This Course Entails

We've designed this course as a learning adventure. It's a way for developers from the Stellar ecosystem and other blockchain communities to experiment, provide feedback, and contribute to the Soroban development process.

As you progress through The Soroban Dapps Challenge, anticipate your code to break and updates to shift things. We invite you to experiment and build but also remind you that changes are afoot as we prepare for the production release.

## Getting Started

To get started, simply head over to the [Dashboard](/docs/learn/interactive/dapps/dashboard), [connect your wallet](../../../smart-contracts/guides/freighter/connect-testnet.mdx), and see what challenges await you!

## Giving Your Feedback

We value your input. Feel free to file issues in the Soroban repos or raise them in the soroban channel in the Stellar Developer [Discord](https://discord.gg/3qrBhbwE).

Join us in this exciting course and start building for the future of blockchain technology.

> Disclaimer: The Soroban Dapps Challenge is for educational purposes only and is designed to teach developers how to write code using Soroban by experimenting in a Sandbox environment. None of the materials provided as part of the Soroban Dapps Challenge shall be construed as financial, legal, or investment advice. Any developers that wish to subsequently launch any Soroban Dapps live on mainnet acknowledge that they do so independently, outside of the Soroban Dapps Challenge program. All such developers should ensure they have considered any applicable legal and compliance obligations in force in their jurisdiction.
82 changes: 82 additions & 0 deletions docs/learn/interactive/dapps/scaffold-soroban.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
sidebar_position: 30
title: Scaffold Soroban
description: Dive into the simple implementations of Soroban dapps to understand and learn the Soroban ecosystem.
---

## Demonstrative Soroban Dapps

import ReactPlayer from "react-player";

The **Soroban** team has invested considerable effort into contract implementation. They’ve built CLI’s and libraries, enabling contract builders to create and invoke using Rust, which forms the “backend” of Soroban. However, the “frontend”, which involves JS client libraries, required attention.

## Background

During the Soroban Hackathon, we recognized that while the frontend libraries were functional, their user experience was far from ideal. Furthermore, the lack of clear examples made it harder for dapp creators to design and understand Soroban's UX.

To tackle this, the **Wallet Engineering** team, in collaboration with the Soroban team, has decided to launch “Scaffold Soroban”, a collection of demo dapps. These dapps demonstrate basic functionalities in a structured, easy-to-follow manner, primarily focusing on how to construct/deploy Soroban contract invocations.

## Dapp Demos

For easy accessibility, we have compiled the dapps into a [single repository](https://github.com/stellar/scaffold-soroban), which contains the following dapps:

### [1. Payment Dapp](https://github.com/stellar/soroban-react-payment)

This dapp mirrors the Soroban payment flow in Freighter by using the wallet’s Soroban token balances to invoke the `xfer` method on the token’s contract.

See the [demo](https://github.com/stellar/soroban-react-payment/releases/tag/v1.0.0)

<ReactPlayer
controls
url="https://user-images.githubusercontent.com/6789586/244450707-2ca53a9c-7493-47a1-aee6-cb126d6e32f8.mp4"
/>

### [2. Mint Token Dapp](https://github.com/stellar/soroban-react-mint-token)

This dapp allows a token admin to mint tokens by using the admin account to invoke the `mint` method on the token’s contract.

See the [demo](https://github.com/stellar/soroban-react-mint-token/releases/tag/v1.0.0)

<ReactPlayer
controls
url="https://user-images.githubusercontent.com/6886006/246495488-1b02da2c-5119-47c6-ab38-fbaa73a26f12.mov"
/>

### [3. Atomic Swap Dapp](https://github.com/stellar/soroban-react-atomic-swap)

This dapp demonstrates a simplified swap between two tokens by using the wallet’s Soroban token balances to invoke the `swap` method on the atomic swap contract.

See the [demo](https://github.com/stellar/soroban-react-atomic-swap/releases/tag/v1.0.0)

<ReactPlayer
controls
url="https://user-images.githubusercontent.com/6886006/258894451-19f4363b-e6e3-4d32-973a-6d99fd0d9847.mov"
/>

## How To Explore the Dapps on Scaffold-Soroban

To begin using these examples, navigate to [Scaffold-Soroban](https://scaffold-soroban.stellar.org/) and choose the name of the dapp you're interested in from the "select demo" dropdown:

- **Payment**: Choose "payment".
- **Token Minter**: Select "mint-token".
- **Atomic Swap**: Opt for "atomic-swap".

Dive in and discover the power of Soroban!

## Functionality Behind the Dapps

With the introduction of these dapps, let's delve deeper into some of their [standout features](https://github.com/stellar/soroban-react-atomic-swap/blob/main/src/helpers/soroban.ts) that showcase the power and innovation behind the dapps:

Functionality behind the dapps is extensive and diverse, leveraging the `@stellar/stellar-sdk` library to integrate with the Soroban RPC and facilitating direct communication with Soroban using a JSON RPC interface on the Stellar network. They are equipped to communicate across different network setups, as they incorporate the `RPC_URLS` and `getServer` functionalities, providing adaptability that is crucial for various development and deployment scenarios. Users can retrieve user-friendly token information without engaging with complex blockchain operations, by utilizing functions like `getTokenSymbol`, `getTokenName`, and `getTokenDecimals`.

A significant feature is the `simulateTx` function, which allows users to preview the outcome of a transaction before actually executing it. `simulateTx` allows users to submit a trial contract invocation by first running a simulation of the contract invocation as defined on the incoming transaction. The results are then applied to a new copy of the transaction, which is returned with the ledger footprint and authorization set, making it ready for signing and sending. The returned transaction will also have an updated fee, the sum of the fee set on the incoming transaction with the contract resource fees estimated from the simulation. It is advisable to check the fee on the returned transaction and validate or take appropriate measures for interaction with the user to confirm it is acceptable.

Other utilities such as `accountToScVal` and `numberToI128` are also provided to simplify transaction creation by converting user-friendly inputs into the formats expected by the Soroban RPC on the Stellar network. Furthermore, the dapps are built with premade helper functions such as the `makePayment` function which facilitates streamlined "transfer" operations and also includes memos for supplementary transaction-related information.

The code referenced showcases various functionalities including sending transactions, retrieving token information, simulating transactions, building swaps, and authorizing contract calls, all of which are ready to be cloned, customized, and expanded upon to suit your unique needs and ideas.

## Conclusion

We hope these dapps will help you understand the Soroban ecosystem better and inspire you to build your own dapps using tools like [stellar-sdk](https://www.npmjs.com/package/@stellar/stellar-sdk) and [freighter-api](https://www.npmjs.com/package/@stellar/freighter-api). We look forward to seeing what you create!

For any queries or discussions, don't hesitate to join us on [Discord!](https://discord.com/channels/897514728459468821/1037073682599780494).
5 changes: 5 additions & 0 deletions docs/smart-contracts/guides/dapps/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Dapp Development
---

We've written some helpful guides on some of the most useful tools available to you, the dapp developer.
136 changes: 136 additions & 0 deletions docs/smart-contracts/guides/dapps/docker.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
title: Use Docker to build and run dapps
---

## What is Docker?

Welcome to the world of [Docker](https://www.docker.com/), an essential tool for software development. Docker packages software into units known as containers, ensuring consistency, isolation, portability, and scalability.

Docker is particularly useful in dapp development. It helps manage microservices, maintain consistent environments throughout development stages, and simulate a decentralized network during testing.

Understanding Docker begins with understanding Docker images and containers. A Docker image, created from a Dockerfile, is a package that contains everything needed to run the software. A Docker container is a running instance of this image.

## Building and Running a Docker Image

You can create a Docker image using the docker build command with a Dockerfile. Once the image is created, you can run a Docker container using the docker run command.

In the context of the example Soroban dapps, understanding how to build Docker images is crucial. The Docker images serve as the basis for our container, which provides the environment for our dapp to run.

Here's an example from our example

To illustrate the process, let's take an example from our [example crowdfund dapp]. In order to build the Docker image, you utilize a command that is encapsulated within our Makefile:

```bash
make build-docker
```

This command simplifies the Docker build process and ensures it's consistently executed each time. When you run `make build-docker`, Docker executes the following instructions:

```bash
docker build . \
--tag soroban-preview:11 \
--force-rm \
--rm
```

### Makefile Overview

```bash
docker build .
```

Instructs Docker to build an image using the Dockerfile in the current directory (denoted by the ".").

```bash
--tag soroban-preview:11
```

Gives a name and tag to our image, in this case, soroban-preview with the tag 9.

```bash
--force-rm
```

Ensures Docker removes any intermediate containers after the build process completes. This keeps our environment clean.

```bash
--rm
```

Guarantees the removal of the intermediate container, even if the build fails. By using `make build-docker`, you're harnessing the power of Docker to create a consistent, reliable environment for our dapp.

## Container Deployment

You can streamline the deployment process by using a script to run the Docker container. The following script is a wrapper for the [`stellar/quickstart` Docker image], which provides a quick way to run a Stellar network. You can find an example of the `quickstart.sh` script located in the root directory of the [example crowdfund dapp].

```bash title="quickstart.sh"
#!/bin/bash

set -e

case "$1" in
standalone)
echo "Using standalone network"
ARGS="--standalone"
;;
futurenet)
echo "Using Futurenet network"
ARGS="--futurenet"
;;
*)
echo "Usage: $0 standalone|futurenet"
exit 1
;;
esac

shift

# Run the soroban-preview container
# Remember to do:
# make build-docker

echo "Creating docker soroban network"
(docker network inspect soroban-network -f '{{.Id}}' 2>/dev/null) \
|| docker network create soroban-network

echo "Searching for a previous soroban-preview docker container"
containerID=$(docker ps --filter="name=soroban-preview" --all --quiet)
if [[ ${containerID} ]]; then
echo "Start removing soroban-preview container."
docker rm --force soroban-preview
echo "Finished removing soroban-preview container."
else
echo "No previous soroban-preview container was found"
fi

currentDir=$(pwd)
docker run -dti \
--volume ${currentDir}:/workspace \
--name soroban-preview \
-p 8001:8000 \
--ipc=host \
--network soroban-network \
soroban-preview:11

# Run the stellar quickstart image

docker run --rm -ti \
--name stellar \
--network soroban-network \
-p 8000:8000 \
stellar/quickstart:testing \
$ARGS \
--enable-soroban-rpc \
"$@" # Pass through args from the CLI
```

The `quickstart.sh` script sets up the Docker environment for running the dapp. It allows you to choose between a standalone network or the Futurenet network. The script performs the following steps:

- Determines the network based on the provided argument (`standalone` or `futurenet`).
- Creates the Docker network named `soroban-network` if it doesn't exist.
- Removes any existing `soroban-preview` Docker container.
- Runs the `soroban-preview` container, which provides the Soroban Preview environment for development.
- Runs the `stellar/quickstart` Docker image, which sets up the Stellar network using the chosen network type and enables Soroban RPC.

[`stellar/quickstart` Docker image]: https://hub.docker.com/r/stellar/quickstart
[example crowdfund dapp]: https://github.com/stellar/soroban-example-dapp
Loading
Loading