Coder Social home page Coder Social logo

blkluv / gift-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paritytech/gift-app

0.0 0.0 0.0 4.56 MB

Send dot/ksm as gifts to anyone and invite them to join polkadot

Home Page: gift-app-fea5f5.spheron.app

License: The Unlicense

JavaScript 83.68% CSS 5.40% HTML 0.45% SCSS 10.47%

gift-app's Introduction

Substrate Gifts

Substrate Gifts is a dapp (decentralized app) built on top of substrate compatible networks. The app lets the users of any substrate based network send tokens as a gift no matter if the recepient has any accounts in the network or not. The sender of a gift can simply wrap their tokens (KSMs, DOTs, etc) as a gift in a unique secret hash that functions as a voucher and share the gift secret with the recipient (through email, message or just simply writing it down on a piece of paper). The recipient of the gift can go to the dapp and reveal the received voucher (gift secret) to redeem their gifted tokens to their account. If the recipient has no accounts in the network to redeem their gift, the dapp will walk them through account creation steps to let them create an account before redeeming their gift.

Running Substrate Gifts dapp

Requirements

Installation

The codebase is installed using git and yarn. This assumes you have installed yarn globally prior to installing it within the subdirectories. For the most recent version and how to install yarn, please refer to yarn documentation and installation guides.

# Clone the repository
git clone https://github.com/paritytech/gift-app.git
cd gift-app
yarn install

Usage

You can start the dapp in development mode to connect to a locally running node.

yarn start

You can also build the app in production mode,

yarn build

and host the build/ folder using any webserver. refer to [vite] (https://vitejs.dev/guide/static-deploy.html) documentations for more info

Configuration

The dapps configuration is stored in the src/config directory, with common.json being loaded first, then the environment-specific json file.

  • development.json affects the development environment
  • production.json affects the production environment, triggered in yarn build command.

When writing and deploying your own dapp, you might need to configure:

  • PROVIDER_SOCKET in src/config/production.json pointing to your own deployed node.
  • DEVELOPMENT_KEYRING in src/config/common.json be set to false if you don't want to load the keyrings usual suspects (Alice, Bob, ...) as test accounts. See Keyring.

Specifying Connecting Node

There are two ways to specify it:

  • With PROVIDER_SOCKET in {common, development, production}.json.
  • With rpc=<ws or wss connection> query paramter after the URL. This overrides the above setting.

Reusable Components

useSubstrate Custom Hook

The custom hook useSubstrate provides access to the Polkadot js API and thus the keyring and the blockchain itself. Specifically it exposes this API.

{
  socket,
  types,
  keyring,
  keyringState,
  api,
  apiError,
  apiState,
  chainInfo,
}
  • socket - The remote provider socket it is connecting to.
  • types - The custom types used in the connected node.
  • keyring - A keyring of accounts available to the user.
  • keyringState - One of "READY" or "ERROR" states. keyring is valid only when keyringState === "READY".
  • api - The remote api to the connected node.
  • apiState - One of "CONNECTING", "READY", or "ERROR" states. api is valid only when apiState === "READY".
  • apiError - the api error if any has happened during connecting to the chain Api
  • chainInfo - the chain information that are configured for the network including chainDecimals, chainTokens, genesisHash, chainSS58 address type and existentialDeposit

gift-app's People

Contributors

hamidra avatar erler avatar dependabot[bot] avatar shawntabrizi avatar eightfivezero avatar imadarai avatar jeluard avatar rmnprkrl 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.