Code Monkey home page Code Monkey logo

example-buy-me-a-coffee's Introduction

Buy me a Coffee

This demo project serves as an example for building a basic dApp for VeChain using dApp-Kit.

It uses as few dependencies as possible, but includes:

  • TypeScript to enhance stability and safety for developers
  • tailwindcss, @headlessui/react, @heroicons/react to improve the UI from an interface perspective
  • @tanstack/react-query to simplified web requests

The project demonstrates the following functionalities:

  • Signing in with VeChain Certificates
  • Building & Sending Transactions
  • Tracking Transaction Status

Start playing with the project immediately with the following steps:

git clone https://github.com/ifavo/example-buy-me-a-coffee.git
cd example-buy-me-a-coffee
npm install
npm start

Scripts

Run

Build

  • To build the website, execute npm run build.
  • The generated output will be located in the dist/ directory.

Application Process

The application prompts the user to sign in using their wallet. It retrieves a list of available tokens from a public GitHub repository, enabling the user to send either VET or a selected token to a specified address. The status of the transaction is monitored and displayed.

sequenceDiagram
participant User
participant Wallet
participant App
participant Blockchain
participant GitHub

note over User, GitHub: Starting the App
User->>App: open app
App->>GitHub: get list of tokens
GitHub-->>App: list of tokens
App-->>User: show tokens and form to enter amount

note over User, App: User Login
User->>App: log in
App->>Wallet: ask for user verification
Wallet->>User: verify identity
User-->>Wallet: approve verification
Wallet-->>App: verification approved
App-->>User: show user's wallet address

note over User, Blockchain: Token Transfer
User->>App: initiate token transfer
App->>Wallet: request transaction signature
Wallet->>User: request signature
User-->>Wallet: provide signature
Wallet-->>Blockchain: send transaction
Blockchain-->>Wallet: transaction ID or error message
Wallet-->>User: show confirmation
Wallet-->>App: send transaction ID or error message

loop until transaction is confirmed
  App->>Blockchain: check transaction status
  Blockchain-->>App: pending, successful, or failed
end

App-->>User: show transaction result
Loading

Application Structure

At the center is the <App /> component, which is responsible for rendering both the layout and the application itself. This component is encapsulated by providers designed to establish global connectivity for VeChain and HTTP requests.

+---------------------- React -------------------------+
|                                                      |
|  +------------- QueryClientProvider ---------------+ |
|  |  by @tanstack/react-query to support useQuery() | |
|  |                                                 | |
|  |  +--------- DAppKitProvider ----------+         | |
|  |  |  @vechain/dapp-kit to enable hooks |         | |
|  |  |                   and connectivity |         | |
|  |  |                                    |         | |
|  |  |               <App />              |         | |
|  |  +------------------------------------+         | |
|  +-------------------------------------------------+ |
+------------------------------------------------------+

Files & Folders:

src
├── App.tsx (Providers and global setup)
├── BuyCoffee (Buy-me-a-Coffee component)
├── Layout
├── common
├── config (configuration settings)
├── index.css
├── index.html
└── index.tsx

example-buy-me-a-coffee's People

Contributors

ifavo 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.