a Bancor based utility-enhanced token protocol

starsStars 60
forksForks 20
watchersWatchers 60
current-versionCurrent version
total-releasesTotal releases 0
open_issues_countOpen issues 0
dateFirst release -
dateLatest release -
updateLast update 2020-07-21

tokendapppub: a bancor based utility-enhanced token protocol

Usage (buy,sell,transfer,publish)

publish your DApp token by yourself. And then, you can buy/sell and transfer your token on the website.

Buy Example

contract: eosio.token
action: transfer
data: {
    "to": "tokendapppub",
    "from": "yourself",
    "quantity": "10.0000 EOS",
    "memo": "TPT-referrer:godofdapppub"

Sell Example

contract: tokendapppub
action: sell
data: {
    "from": "yourself",
    "quantity": "100.0000 PUB"

Consume Example

If you are a developer and you want to pushlish a utility token for consuming on your DApp. after you publish your token, you should wirte a contract to do this. after you set your code on EOS mainnet, when user consume your token, we will notify your contract by require_receiption in tokendapppub contract. The consume Richard Contract is here.

  • example.hpp
#include <eosiolib/eosio.hpp>
#include <eosiolib/symbol.hpp>
#include <eosiolib/asset.hpp>

#include <math.h>

using namespace eosio;
using namespace std;

const symbol_type EXAMPLE_SYMBOL = S(4, EXAMPLE);

class example: public contract {
    example(account_name self):
    void consume(account_name from, asset quantity, string memo);
    void receipt(account_name from, asset quantity);

#ifdef ABIGEN
    EOSIO_ABI(example, (receipt))
  • example.cpp
#include "example.hpp"

void example::consume(account_name from, asset quantity, string memo) {
    eosio_assert(quantity.is_valid(), "invalid quantity");
    eosio_assert(quantity.symbol == EXAMPLE_SYMBOL, "symbol mismatch");

    // TODO: your business logic

            permission_level{_self, N(active)},
            make_tuple(from, quantity)

void example::receipt(account_name from, asset quantity) {

extern "C" {
    void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
        example thiscontract(receiver);

        if((code == N(tokendapppub)) && (action == N(consume))) {
            execute_action(&thiscontract, &example::consume);

        if (code != receiver) return;

        switch (action) {
            EOSIO_API(example, (receipt))

Token Exchange

Block Explorer