Coder Social home page Coder Social logo

pinkdiamond1 / soroban-example-dapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stellar/soroban-example-dapp

0.0 1.0 0.0 1.43 MB

End-to-End Example Soroban Dapp

License: Apache License 2.0

Shell 3.79% JavaScript 0.38% Rust 18.82% TypeScript 66.32% CSS 9.42% Makefile 1.28%

soroban-example-dapp's Introduction

Soroban Crowdfunding Dapp Example

Screenshot of the Example Dapp

This is a Next.js project, demoing how to build a dapp frontend backed by smart contracts on Stellar.

Getting Started

Dependencies

  1. Install the soroban-cli from https://soroban.stellar.org/docs/getting-started/setup#install-the-soroban-cli
  2. Install Docker for Standalone and Futurenet backends.

Backend (Local Sandbox)

  1. Run the backend with soroban-cli serve
  2. Run ./initialize.sh sandbox to load the contracts and initialize it.
  • Note: this will create a .soroban sub-directory, to contain the sandbox network data.
  1. Configure Freighter a. Install the custom Freighter Soroban release from https://github.com/stellar/freighter/releases/tag/v2.6.0-beta.2 b. Enable "Experimental Mode" in the settings (gear icon). c. Add a custom network:
    Name Sandbox
    URL http://localhost:8000/soroban/rpc
    Passphrase Local Sandbox Stellar Network ; September 2022
    Allow HTTP connection Enabled
    Switch to this network Enabled

Backend (Local Standalone Network)

  1. Run the backend docker container with ./quickstart.sh standalone, and wait for it to start.
  2. Run ./initialize.sh standalone to load the contracts and initialize it.
  • Note: this state will be lost if the quickstart docker container is removed.
  1. Configure Freighter a. Install the custom Freighter Soroban release from https://github.com/stellar/freighter/releases/tag/v2.6.0-beta.2 b. Enable "Experimental Mode" in the settings (gear icon). c. Add a custom network:
    Name Standalone
    URL http://localhost:8000/soroban/rpc
    Passphrase Standalone Network ; February 2017
    Allow HTTP connection Enabled
    Switch to this network Enabled
  2. Add some Standalone network lumens to your Freighter wallet. a. Copy the address for your freighter wallet. b. Visit http://localhost:8000/friendbot?addr=<your address>

Backend (Futurenet)

  1. Run the backend docker container with ./quickstart.sh futurenet, and wait for it to start.
  • Note: This can take up to 5 minutes to start syncing. You can tell it is working by visiting http://localhost:8000/, and look at the ingest_latest_ledger, field. If it is 0, the quickstart image is not ready yet.
  1. Run ./initialize.sh futurenet to load the contracts and initialize it.
  2. Configure Freighter a. Install the custom Freighter Soroban release from https://github.com/stellar/freighter/releases/tag/v2.6.0-beta.2 b. Enable "Experimental Mode" in the settings (gear icon). c. Add a custom network (Note, the out-of-the-box "Future Net" network in Freighter will not work with a local quickstart container, so we need to add our own):
    Name Futurenet
    URL http://localhost:8000/soroban/rpc
    Passphrase Test SDF Future Network ; October 2022
    Allow HTTP connection Enabled
    Switch to this network Enabled
  3. Add some Futurenet network lumens to your Freighter wallet.

Frontend

Then, run the development server:

npm run dev

Open http://localhost:3000 with your browser to see the result.

Note: Before you can "Approve transfer & Back this project", you'll need to have some EXT (example token) in your freighter wallet. There is a "Mint 100 EXT" button, which will gift you 100 EXT tokens for that purpose.

User Workflows

The contract dev should be able to:

  • Clone the example repo (this one)
  • Choose their target amount and deadline
  • Deploy their contract to futurenet
  • Deploy a soroban rpc server somewhere (TBD)
  • Deploy the example web ui somewhere (e.g. netlify)

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

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

Wallet Integration & Data Fetching

There is a ./wallet directory, which contains a small library to connect to the user's freighter wallet, as well as some React hooks to talk to a soroban-rpc server (e.g. soroban-cli serve), to fetch data and send transactions.

Data from contracts is fetched using the useContractValue hook in ./wallet/hooks/useContractValue.tsx. Transactions are submitted to the network using the useSendTransactions hook in ./wallet/hooks/useSendTransaction.tsx.

soroban-example-dapp's People

Contributors

lucasmagnus avatar paulbellamy avatar sisuresh avatar stellar-terraform avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.