salman01zp / SubstrateTokens

Substrate main Node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Substrate Pallets

This is a project for learning exploring blockchain runtime development with Substrate and the FRAME. This project implements a simple substrate based pallets listed below

Crowdfunding Pallet Design Overview

Calls

This pallet defines a simple crowdfunding application interface throw which user can interact and contribute

  • create(origin, beneficiary, goal, end)
  • contribute(origin,index,value)
  • withdraw(origin,index)
  • dissolve(origin, index)
  • dispense(origin, index)

Data Structure

pub struct FundInfo<AccountId, Balance, BlockNumber> {
  pub beneficiary:      AccountId,
  pub deposit:          Balance,
  pub raised:           Balance,
  pub end:              BlockNumber,
  pub goal:             Balance
}
type FundIndex = u32;
type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
type BalanceOf<T> = << T as Config>::Currency as Currency<AccountIdOf<T>>>::Balance;
type FundInfoOf<T> = FundInfo<AccountIdOf<T>, BalanceOf<T>, <T as frame_system::Config>::BlockNumber>;

Storages

-funds: StorageMap FundIndex =>FundInfoOf

-fund_count: StorageValue => u32

Events

  • Created(FundIndex, T::BlockNumber)
  • Contributed(T::AccountId, FundIndex, BalanceOf<T>, T::BlockNumber)
  • Withdrew(T::AccountId, FundIndex, BalanceOf<T>, T::BlockNumber)
  • Retiring(FundIndex, T::BlockNumber)
  • Dissolved(FundIndex, T::BlockNumber, T::AccountId)
  • Dispensed(FundIndex, T::BlockNumber, T::AccountId)

Errors

  • EndTooEarly
  • ContributionTooSmall
  • InvalidIndex
  • ContributionPeriodOver
  • FundStillActive
  • NoContribution
  • FundNotRetired
  • UnsuccessfulFund

Token Pallet Design Overview

Calls

This pallet defines a simple token creation and transfer interface.

  • initialize_token(origin_id)
  • transfer_token(from_id,to_id,amt)

Storages

-Balances: StorageMap AccountId =>token_balance

-TotalSupply: StorageValue => u64

Events

  • Initialized(AccountId)
  • TokenTransfered(from_id, to_id , amount)

Errors

-AlreadyInitialized

-InsufficientFunds

-TokenOverflow

Build & Run

If you need to, set up your Substrate development environment. Then, build and run a development chain:

$ cargo run -- --dev --tmp

Once the node is running, use this link to open the Polkadot JS Apps UI and connect to the Substrate node: https://polkadot.js.org/apps/#/settings/developer?rpc=ws://127.0.0.1:9944. Use the Settings > Developer app and the contents of the types.json file to add the necessary types to the UI.

This project was forked from the Substrate Developer Hub Node Template.

About

Substrate main Node


Languages

Language:Rust 97.4%Language:Nix 1.8%Language:Shell 0.8%