Giter VIP home page Giter VIP logo

crowdloan-rewards's Introduction

Crowdloan Rewards Pallet

Distribute rewards for crowdloan participation in parachain-native tokens.

Context

Polkadot and Kusama will allocate parachain slots using an [auction mechanism] (https://wiki.polkadot.network/docs/en/learn-auction). Bidders can be normal relay chain accounts, or crowdloans. A parachain project may use a crowdloan to allow its community to pool funds to bid for a slot. Pooled funds will be locked up, so parachain projects will need to reward their community for taking the opportunity cost of locking tokens in a crowdfund.

Design Overview

There are good docs in the crate. For now see them in src/lib.rs.

Using this pallet in your parachain runtime

First you will need to make sure your project is using the same Substrate dependencies as this pallet.

In your Cargo.toml file:

[dependencies]
# --snip--
pallet-crowdloan-rewards = { git = "https://github.com/purestake/crowdloan-rewards", default-features = false, branch = "main" }

[features]
default = ['std']
std = [
  # --snip--
  'pallet-crowdloan-rewards/std',
]

In your lib.rs file:

parameter_types! {
    pub const Initialized: bool = false;
    pub const MinimumReward: Balance = 1000;
    pub const InitializationPayment: Perbill = Perbill::from_percent(25);
    pub const MaxInitContributorsSize: u32 = 500;
    pub const RewardAddressRelayVoteThreshold: Perbill = Perbill::from_percent(100);
    pub const SignatureNetworkIdentifier: &'static [u8] = b"chain-name";
}

impl pallet_crowdloan_rewards::Config for Runtime {
    type RuntimeEvent = RuntimeEvent;
    type Initialized = Initialized;
    type InitializationPayment = InitializationPayment;
    type MaxInitContributors = MaxInitContributorsSize;
    type MinimumReward = MinimumReward;
    type RewardAddressRelayVoteThreshold = RewardAddressRelayVoteThreshold;
    type RewardCurrency = Balances;
    type RelayChainAccountId = sp_runtime::AccountId32;
    type RewardAddressChangeOrigin = EnsureSigned<AccountId>;
    type SignatureNetworkIdentifier = SignatureNetworkIdentifier;
    type RewardAddressAssociateOrigin = EnsureSigned<AccountId>;
    type VestingBlockNumber = cumulus_primitives_core::relay_chain::BlockNumber;
    type VestingBlockProvider = cumulus_pallet_parachain_system::RelaychainBlockNumberProvider<Self>;
    type WeightInfo = pallet_crowdloan_rewards::weights::SubstrateWeight<Runtime>;
}

construct_runtime! {
	// --snip--
	CrowdloanRewards: pallet_crowdloan_rewards
}

In your chain_spec.rs file:

const CROWDLOAN_FUND_POT: u128 = 1_000_000_000_000_000_000_000_000_u128; // Total reward amount
	
	
// Add crowdloan config in testnet_genesis
crowdloan_rewards: CrowdloanRewardsConfig {
	funded_amount: crowdloan_fund_pot,
},

crowdloan-rewards's People

Contributors

girazoki avatar joshorndorff avatar notlesh avatar dependabot[bot] avatar polkaverse avatar tgmichel avatar librelois avatar crystalin 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.