Joifsi
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # StakeDrop Integration StakeDrop in Marlin is a way to distribute marlin tokens among communities to ensure that the governance is distributed. It also ensures that marlin tokens are not a barrier for potential node runners. StakeDrop is supported for a set of blockchain platforms initially decided by the Marlin team during launch, but later this decision lies with the governance where anyone with marlin tokens can participate. StakeDrop for any given blockchain platform is designed in a way that users who have tokens of the blockchain, can earn rewards by delegating their tokens to validators who use Marlin network for Block propagation. This incentivizes validators to use Marlin protocol to increase tokens delegated to them, thus bootstrapping the supply and demand side for the bandwidth marketplace. A fixed number of marlin tokens are rewarded to the users for a fixed period of time. Rewards are distributed based on the number of tokens delegated to validators who use the Marlin network. ## Architecture Stakedrop is implemented in Marlin as a set of oracles which feed data to a distribution contract that calculates the rewards from the data feed from oracles. Users can claim their rewards by sending a transaction to the distribution contract. Oracles Stakedrop uses the following oracles to feed the data required to calculate rewards * Address Registry * Validator Registry * Stake Registry ### Address Registry Address registry contains the delegator address and their corresponding Ethereum addresses. The Ethereum address is used to reward marlin tokens (ERC20 on Eth), to delegators who delegate stake to validators using Marlin. A delegator who wants to register for stakedrop will link their delegation address with a corresponding Ethereum address from our stakedrop portal. There are multiple approaches we use based on the availability of tools for the blockchain ecosystem and the simplest mechanism for the user to follow. Some of the approaches are verifying a signature generated by the delegator address on the Ethereum address or sending a transaction from the delegator address to a specific address generated based on the ethereum address. ### Validator Registry Validator registry maintains the list of validators who use Marlin protocol for data propagation at any specific epoch. Validator list has to be feeded to this registry for each epoch and after entering all the validators for the epoch, the validator list has to be freezed, so that rewards can be equally distributed as we know the total stake eligible for rewards. ### Stake Registry Stake Registry maintains the mapping of delegator and the amount of stake delegated by the delegator to validators using Marlin. Stake for each delegator has to be feeded to the registry for each epoch and based on this feed rewards are allocated to each delegator based on their delegated stake. ### Distribution Contract Distribution contract maintains the amount of rewards claimed by the delegators and the rewards which are pending to be withdrawn. Delegators can claim their rewards from this contract. Delegators can withdraw rewards they have earned till the last epoch but the rewards for the current epoch can’t be withdrawn till the epoch ends. ## Feeder A transaction feeder is developed by Marlin which can ease the integration of stakedrops for new blockchain platforms as the feeder does the job of converting the API calls made to the feeder into the Ethereum transactions necessary to feed the data into blockchain. The following are API provided by the transaction feeder * addValidator {epoch, validatorAddres} * freezeEpoch {epoch} * addTotalStake {epoch, stakeValue} * addDelegator {epoch, stakingAddress, validatorAddress, amount} * addAddress {stakingAddress, ethereumAddress} * removeAddress {stakingAddress, ethereum} Epoch here is the time period for which data is updated for rewards on the blockchain. This also is the frequency with which data is to be provided to the oracles. The order in which these APIs needs to be called based on how the oracles work is as follows * Add all the validators for a specific epoch by calling addValidator endpoint. * Once all the validators are added, freeze the epoch by invoking freezeEpoch endpoint. * Add total stake from the validators who are using marlin by using addTotalStake endpoint. * Add the stake of each of the delegators for a specific epoch by using the addDelegator endpoint. * addAddress and removeAddress to add delegators can be added at any point and the rewards will be calculated from the block that the addAddress transaction is sent. **Note:** Ordering of the transactions is to be done before invoking the transaction feeder APIs and transaction feeder itself doesn’t validate the ordering. ### Integration To integrate the stake drop for a new blockchain platform, the data source necessary for the feeder needs to be implemented. The data source can use feeder APIs to feed data to the oracles necessary for the stakedrop. ## UI Integration We have developed a website for stakedrop which can be used by any of the new blockchain platforms integrating for the stakedrop. ### High level Flow * User registers for stakedrop by linking the staking address to the reward address(ETH address). * Staking address can be linked by sending a 0 value transaction from staking address to the random address, which is generated based on the combination of staking address and reward address. * For example, random address can be generated with concatenation of staking address and reward address as seed. * The above transaction should be made and transaction hash should be submitted within 24hrs of the transaction. * If successful the user is added as a valid stakedrop participant. * Validators of the base chain who support Marlin are whitelisted. Only the stake delegated to these validators by the registered delegators is considered for the reward. ### Interfaces Swagger Docs - sd2.api.marlin.pro/polkadot/api-docs Below are the APIs necessary to integrate with the existing User Interface. Ethereum address is the reward address in the following section. **GET /getTotalValueLocked** -- Total stake delegated by registered users to whitelisted validators. **GET /generateDepositAddress/:stakingAddress/:ethereumAddress** -- Generate a new address to send a 0 value tx to register staking address with ethereum address. The generated address should be unique for a given staking and ethereum address. “:stakingAddress” and “: ethereumAddress” are the parameters to be passed to the endpoint. Ethereum address and staking address are mapped one to one i.e multiple ethereum address cannot be linked to a single staking address or multiple staking address cannot be linked to a single ethereum address. **GET /isEthereumAddressAvailable/:ethereumAddress** -- This endpoint is used to check if the ethereum address provided is already linked with any other staking address. **GET /isStakingAddressAvailable/:stakingAddress** -- This endpoint is used to check if the staking address provided is already linked with any other ethereum address **POST /register** Data: { stakingAddress ethereumAddress transactionHash } This endpoint is used to register a delegator by linking the delegator’s staking address to the Ethereum reward address. Below are some of the important checks we perform for reference. * Validate data formats for the data received * Check if staking address, reward address are valid * Validate if the transaction hash is related to a tx within last 24hrs. * Check if the sender is the staking address and receiver is the generated address based on staking and ethereum addresses and value is 0. * Check if staking and ethereum addresses are not already registered. The delegator can then be registered for stake drop. **GET /contractAddress** -- This endpoint returns the contract address for the distribution contract for the user interface. **GET /transaction/:hash** -- Check if the transaction hash is valid. **POST /addWhiteListedValidator** Data: { key, validatorAddress } This endpoint adds whitelisted validator addresses by the admin after confirmation that they use Marlin. Key represents the authorization data necessary to authenticate admin and validatorAddress is the address to be whitelisted.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully