Skip to main content

Crowdfund Dapp Challenge

This challenge will guide you through the process of building and shipping a crowdfunding dapp on Stellar using Soroban. You will learn how to deploy smart contracts to Futurenet, and how to interact with them through a web frontend. In this context, the term "ship" refers to finalizing the development process of your dapp, ensuring that it functions as expected, and is accessible for user interaction and testing through a hosted frontend. However, it's crucial to clarify that despite its functionality, the dapp is not promoted nor intended for deployment in a production-level setting on Futurenet. The challenge is designed for educational purposes, helping you understand how a dapp can be built and interacted with, with further customization and development, it has the potential to evolve into a full-fledged, ready-to-use crowdfunding solution.

Checkpoint 0: πŸ“¦ Install πŸ“šβ€‹

Start by installing the required dependencies.

Required:

First, clone the Soroban example dapp repo and check out the challenge branch:

git clone https://github.com/stellar/soroban-example-dapp
cd soroban-example-dapp
git checkout challenge

Then, install soroban-cli alias by running the following command:

cargo install_soroban

Next, make sure that your Docker daemon is running by either opening Docker Desktop (recommended) or following the instructions provided here.

Then, and build the soroban-preview docker image:

make build-docker

Building the docker image lets you avoid installing the specific version of soroban-cli if desired.

Checkpoint 1: πŸš€ Launch Backend πŸŒβ€‹

Open your Docker Desktop app and make sure it is running. Then run the following command to start the backend:

./quickstart.sh standalone

and wait for it to start.

Checkpoint 2: 🎬 Deploy Smart Contracts​

Now that the backend environment is set up, we need to deploy our smart contracts to in a sandbox environment.

In another terminal, load the contracts and initialize them on the Standalone network by running the following commands:

npm run clean
NETWORK=standalone npm run setup

If the command runs successfully, your terminal will return a series of messages notifying you about the successful initialization of the contracts and the post-installation sequence.

Contract deployed successfully with ID: CBXHU5BWWTOCZRYX3DMSSKCFG7B3K2YG2I5F75ALPQ6GCY6ZES2XKLTI
Deploy the crowdfund contract
Contract deployed successfully with ID: CBKY7UN5VGD4LIQFOBOTSUSQWK67BZZTA23NIEVWSWRR5SAT26JQN2BN
Initialize the abundance token contract

Initialize the crowdfund contract

Done

> [email protected] build-contracts
...
caution

Please, save your deployed contract ID, you will need it to complete the challenge.

Checkpoint 3: 🀝 Connect the Frontend to the Backend​

First, start the development server:

npm run dev

Now open your browser and visit http://localhost:3000. You should be able to see the frontend of your dapp.

Note: Follow the instructions below and ensure that you have funded your wallet address that you intend to use from browser, otherwise the dapp display will be blank and a 'Account not found' will be printed on browser's console only.

Now that we have the frontend running, it's time to connect it with our smart contracts.

First, be sure that you have properly configured the Freighter Wallet by following the instructions here.

Then, add the Standalone network in Freighter:

  • Name: Standalone
  • URL: http://localhost:8000/soroban/rpc
  • Passphrase: Standalone Network ; February 2017
  • Allow HTTP connection: Enabled
  • Switch to this network: Enabled

Next, add some Standalone network lumens to your Freighter wallet by doing the following:

  • Copy the address for your freighter wallet.
  • Visit http://localhost:8000/friendbot?addr=<your_address>

Note: These are test lumens for use with your local network and cannot be used on Futurenet or Mainnet

Checkpoint 4: 🏦 Mint Tokens for the Crowdfunding Campaign​

Open the dapp frontend and click on the "Mint 100 ABND" button.

You should see a popup from Freighter asking you to sign the transaction. Click on "Approve" and wait for the transaction to be confirmed.

You should see an updated balance in the pledge component.

Note: These are test tokens for use with your local network and cannot be used on Futurenet or Mainnet

Checkpoint 5: πŸ’° Fund the Crowdfunding Campaign​

Now that you have your wallet set up, let's fund the crowdfunding campaign.

Open the frontend and click on the "Back this project" button. You should see a popup from Freighter asking you to sign the transaction.

Click on "Approve" and wait for the transaction to be confirmed.

Once the transaction is confirmed, you should see a success message.

You should see an updated balance in the amount you have pledged in the pledge component.

Checkpoint 6: 🚒 Ship it! πŸšβ€‹

Now that your dapp is fully functional locally, next prepare it for deployment on Futurenet.

Stop the development server by pressing ctrl+c in the terminal where it is running.

If you are running docker, now is a good time to stop the Stellar and Soroban preview containers.

docker stop stellar soroban-preview

Then, run the following commands to initialize the contracts on Futurenet:

npm run clean
npm run setup

Then run the dev server again:

npm run dev

Now, open your browser and visit http://localhost:3000.

Ensure that you are connected to Futurenet and you should be able to see the frontend of your dapp!

Next, you will use the Vercel cli to complete our deployment.

Note: If you don’t already have a Vercel account, you will need to create one and link it to your GitHub account.

First install the Vercel cli:

npm i global vercel

Then, run the following command to deploy your dapp:

npx vercel

Then, continue through the prompts (you will not need to modify any settings) until you reach the completion prompt similar to the following:

Vercel CLI 30.1.1
πŸ”— Linked to julian-dev28/soroban-example-dapp (created .vercel)
πŸ” Inspect: https://vercel.com/julian-dev28/soroban-example-dapp/C1YZVQSqh6WcyR1uvxz8q2tW1tjD [2s]
βœ… Production: https://soroban-example-dapp-rho.vercel.app [42s]
caution

Please, save your production url, you will need it to complete the challenge.

You can now visit the preview link to see your deployed dapp! πŸŽ‰

You will need to add some Futurenet network lumens to your Freighter wallet to interact with the deployed dapp. Visit https://laboratory.stellar.org/#account-creator?network=futurenet, and follow the instructions to create your Freighter account on Futurenet.

Checkpoint 7: πŸ’ͺ Pass the Challenge!​

Submit your public url to the challenge form and proceed to the next step to check your work.

Please connect to Testnet network.

info

Join our Community in Discord in case you have any issues or questions.

Checkpoint 8: βœ… Check your work!​

In order to successfully complete this challenge, your work needs to be checked. Please, follow this steps:

  1. Fork the challenge repository.
  2. Fill crowdfund/challenge/output.txt file with your wallet address, contract ID and production url. Filled file should look like:
public key: GBSXUXZSA2VEXN5VGOWE5ODAJLC575JCMWRJ4FFRDWSTRCJ123456789
contract Id: CBKY7UN5VGD4LIQFOBOTSUSQWK67BZZTA23NIEVWSWRR5SAT26JQN2BN
production: https://soroban-example-dapp-rho.vercel.app
  1. Create a Pull Request to the stellar/soroban-dapps-challenge/main branch. When the PR will be created, CI actions will check the crowdfund/challenge/output.txt file data and update your progress.
  2. Wait for the CI/CD pipeline results.
  3. Fix errors if present:
  • find the error reason in the Crowdfund challenge CI results (you can find a link right in the pull request);
  • return to your forked repository;
  • fix errors and commit changes. The existing PR will be checked again.
  1. If the pipeline was successful, then congratulations! You completed the challenge!πŸ‘

Invite a friend to try out your dapp and ask them to provide feedback!

βš”οΈ Side Quests​

🌐 Explore Stellar Laboratory to inspect your account assets on Futurenet.

You should see something like this:

  "balances": [
{
"balance": "100.0000000",
"limit": "922337203685.4775807",
"buying_liabilities": "0.0000000",
"selling_liabilities": "0.0000000",
"last_modified_ledger": 148108,
"is_authorized": true,
"is_authorized_to_maintain_liabilities": true,
"asset_type": "credit_alphanum4",
"asset_code": "ABND",
"asset_issuer": "GBUGENT4FK4Y6FZNZEEGVZJLCHKNES23FRVOPPOI62RUF4WRSNOTSZV4"
},
]

πŸ“š User Workflows Checklist​

During this exercise you should be able to:

  • Clone the example repo (Crowdfund Dapp)
  • Choose your target amount and deadline
  • Deploy your contract to Futurenet
  • Deploy the example web ui somewhere (e.g. netlify, vercel, surge, etc.)

Then via the web UI, you should be able to:

  • Connect your wallet
  • See your current balance(s)
  • See the current fundraising status (total amount & time remaining)
  • See allowed assets
  • Deposit an allowed asset
  • See your deposit(s) appear on the page as the transactions are confirmed.
  • "Live"-Update the page with the total amount with the new amount