In this chapter, you will understand how to set up Airdrop mission via FsTK APi. You can set up Airdrop Locate rule, extract corresponding address on FsTK Engine and airdrop desired assets.

Table of Contents

  1. Prerequisite
  2. Encode the Transaction (creating airdrop)
  3. Decrypt the Ethereum Key JSON
  4. Sign the Ethereum Transaction
  5. Broadcast the Ethereum Transaction
  6. Confirm the Ethereum Transaction
  7. Confirm the Airdrop mission
  8. Check the progress of Airdrop mission
  9. Finalize the Airdrop mission
    1. Prerequisite
    2. Encode the Transaction (finalizing airdrop mission)

Prerequisite

  1. Please sign up an account on https://test.fstk.io or https://engine.fstk.io.

    Notice account data are NOT shared across both platform.

    • test.fstk.io is Tokeneden built on Kovan Testnet for agile software development, testing & demo.
    • engine.fstk.io is official Tokeneden built on Ethereum Mainnet.
  2. Please take a look at your asset balances of ETHFSTFIL and FST Service Gas.

    Please remember that assets on test.fstk.io belongs to Kovan Testnet; assets on engine.fstk.io belongs to Mainnet.

    • ETH is Ether, a small amount will be given to new accounts on test.fstk.io.
    • FST is Funder Smart Token, a fundamental Utility Token within FST Network and will be given to new accounts on test.fstk.io.
    • FIL is FundersToken Initialisation License as Token Issuance License, 1 FIL will be given to new accounts on test.fstk.io.
    • FST Service Gas is the FsTK module usage fee for Token Issuer, balance is shown at User Profile on the top right corner.
  3. Please prepare your API testing tools.
  4. Understand how to retrieve Access Web Token (JWT).

    Please refer to Quick start Chapter 1.

  5. Complete Quick start.
  6. Confirm sufficient Ether (ETH) for ETH gas fee.
  7. Confirm sufficient FST Service Gas for module service fee (at least 90 FST Service Gas), FST Service Gas will not be refunded after cancellation.
  8. Become Issuer (Token Issuer), please confirm token in get me.

Encode the Transaction (create airdrop locate)

In any of following API calls, please remember to assign access token to authorization in http request header.

Hereinafter let’s take FST Sport Shop as the example.

  • Using GraphQL (Insomnia recommended)
    • operations detail

    Variables:

    • rules are Airdrop Locate rules that each rule acts independently.
      • rule is an individual airdrop locate rule.
        • type contains 2 types EVERY and AT_LEASTEVERY means every condition will be counted for giveaway item calculation. For example, ‘every 10 Smart Token can receive 1 Smart Voucher’ means that a customer with 25 Smart Token can receive 2 Smart Voucher. AT_LEAST means only the condition is greater than or equal to (>=) the qualification will be counted for giveaway item calculation. For example, ‘at least 10 Smart Token can receive 1 Smart Voucher’ means that a customer with 25 Smart Token can receive 1 Smart Voucher.
        • itemId is the ID of located Smart Token/Voucher.
        • amount is the located amount of located Smart Token/Voucher in Decimaled Number. Please notice that Smart Token’s decimal is 18 and Smart Voucher’s decimal is 0.
      • itemId is the ID of giveaway Smart Token/Voucher.
      • amount is the giveaway amount of Smart Token/Voucher in Decimaled Number. Please notice that Smart Token’s decimal is 18 and Smart Voucher’s decimal is 0.

Please pay attention to the Decimaled Number based on difference of located item & giveaway item. For example, locating Smart Token to give away Smart Token requires decimals of both rules.n.rule.itemId and rules.n.itemId to be 18. Over-giveaway could occur if given any of the incorrect amount.

  • Using cURL
  • Response

    Setting up Airdrop Locate will not consume FST Service Gas.

    If API succeeds, then your Airdrop Locate rule (here referenced as seqno) is also stored in systems of FST Network. You may use the reference to start Airdrop in the future. Please take down your Airdrop Locate rule seqno and FST Network does not provide this value.

    e.g. Response like

    means the transaction will fail. We suggest to skip the following steps and check related resources of Transaction are correct first. e.g. ETH balance, FST Service Gas balance, Token balance, Voucher balance, … etc..

Create Airdrop Mission

In any of following API calls, please remember to assign access token to authorization in http request header.

Hereinafter we take FST Sport Shop as the example.

  • Using GraphQL (Insomnia recommended)
    • operations detail

    Variables:

    • listId is the seqno from previous step, i.e. the Airdrop Locate rule ID.
    • itemId is the ID of giveaway Smart Token/Voucher during this Airdrop.
    • budget is the budget of Airdrop. Insufficient budget will cause failure of Airdrop.
    • invokeTime is the Airdrop time in Unix time millisecond, e.g. UTC+8 2019/12/31 means "1577807999000". Please notice that Unix time has no time zone, please adjust it according to your local time.
  • Using cURL
  • Response

    Create Airdrop Mission will consume 90 FST Service Gas. Cancelling an Airdrop will not refund FST Service Gas.

    Issuer will consume 0.3 FST Service Gas per airdrop receiver with 90 FST Service Gas as minimum. To airdrop over 300 receivers, each will charge 0.3 FST Service Gas per person.

    In response’s transaction, object will be used to sign payload, submitToken is also required for broadcasting signed transaction.

    Please remember that response will vary after each call, please use the latest response for next steps.

    e.g. Response like

    means the transaction will fail. We suggest to skip the following steps and check related resources of Transaction are correct first. e.g. ETH balance, FST Service Gas balance, Token balance, Voucher balance, … etc..

Decrypt the Ethereum Key JSON

Please notice the difference between password and passphrase in FsTK system. password is required to sign in Tokeneden; passphrase is required to decrypt Ethereum key JSON and sign the transaction.

Word usage may be different in other libraries, i.e. passphrase means password.

To start with, use get me to fetch ethereumKey like the following:

This is current user’s Ethereum key JSON, which includes encrypted private key (by passphrase). This can be safely stored but remain private unless necessary.

Owning private key means owning the Ethereum Account. Please securely store Ethereum key JSON and passphrase.

WARNING: If the passphrase of Ethereum key JSON is lost, the private key is lost and FsTK does not have users’ Ethereum key JSON passphrase.

  • Using JavaScript (Node.js)

    Install eth-key-lib

    This is the module import of ES6. If your node.js does not support it, please refer to Webpack (target = "node") and the followings:

    Minimal webpack.config.js

    Minimal package.json

    Install command line (please let index.js be the program entry point).

    If working on windows, please refer to node-gyp on windows.

  • Using Java

    Please refer to Web3j. Notice that loadCredentials in WalletUtils method with this overload:

    In another way, as web3j only provides File import, please pay attention to OS storage or use in-memory-fs in Java.

    Please to refer to Web3j sample codes.

  • Using C#

    Please refer to Nethereum. Please refer to Nethereum sample codes.

    Please use Account.PrivateKey to fetch private key from Account.

Sign the Ethereum Transaction

  • Using JavaScript
  • Using Java

    Please refer to Web3j. Notice that signMessage in TransactionEncoder, and please use the overload below since the chainId must be included in the signature process.

    Please refer to Web3j sample codes

  • Using C#

    Please refer to Nethereum. Please refer to SignTransaction in TransactionSigner, and please use the overload below since the chainId must be included in the signature process.

    Please refer to the section Nethereum.Web3.Accounts.AccountSignerTransactionManager.SignTransaction.

Broadcast the Ethereum Transaction

  • Using GraphQL (Insomnia recommended)

    Variables:

    data is the object from signing transaction with current user’s private key. In another word, signedTransaction is the hex string.

    submitToken is submitToken from Encode Ethereum Transaction.

  • Using cURL
  • Response

    transactionHash can be used to check whether transaction is confirmed in the next steps.

Confirm the Ethereum Transaction

  • Using GraphQL (Insomnia recommended)

    Variables:

    txHash is the transaction hash.

    Notice that transaction hash is unique on chain, but it may repeat when representing different transactions on different chain.

  • Using cURL
  • Response

    When remain in confirmations becomes 0, the transaction is confirmed.

    Notice that a confirmed transaction may not succeed. As on Blockchain, failed transaction is also a consensus. Please use Infura with ETH-JSON-RPC to fetch status (success/failure of transaction).

Confirm the Airdrop mission

Please refer to getAirdropMissionInfo to retrieve Airdrop info (More details in API_Reference/Airdrop/getAirdropMissionInfo).

Check the progress of Airdrop mission

In any of following API calls, please remember to assign access token to authorization in http request header.

  • Using GraphQL (Recommended Insomnia)
    • operations detail
  • Using cURL
  • Response

Finalize the Airdrop mission

Prerequisite

An airdrop mission has several phases as below.

Encode the Transaction

In any of following API calls, please remember to assign access token to authorization in http request header.

Hereinafter we take FST Sport Shop as the example.

  • Using GraphQL (Insomnia recommended)
    • operations detail

    Variables:

    • missionId is the ID of finalizing Airdrop.
  • Using cURL
  • Response

    Finalizing Airdrop will not consume FST Service Gas.

    Is API succeeds, please follow 3 previous steps: 3. Decrypt the Ethereum Key JSON4. Sign the Ethereum Transaction5. Broadcast the Ethereum Transaction.

    e.g. Response like

    means the transaction will fail. We suggest to skip the following steps and check related resources of Transaction are correct first. e.g. ETH balance, FST Service Gas balance, Token balance, Voucher balance, … etc..