Skip to content
a Bancor based utility-enhanced token protocol
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
logo
tests first commit Aug 28, 2018
.gitignore
Bancor based utility-enhanced token protocol.md
Bancor based utility-enhanced token protocol.pdf
CMakeLists.txt
UnitTestsExternalProject.txt first commit Aug 28, 2018
readme.md
tokendapppub.buy_rc.md
tokendapppub.claim_rc.md
tokendapppub.consume_rc.md
tokendapppub.cpp
tokendapppub.destroy_rc.md
tokendapppub.hellodapppub_rc.md update rc Sep 19, 2018
tokendapppub.hpp
tokendapppub.newtoken_rc.md
tokendapppub.receipt_rc.md
tokendapppub.reg_rc.md
tokendapppub.sell_rc.md
tokendapppub.transfer_rc.md
tokendapppub_rc.md
基于班柯的实用增强型通证协议.md
基于班柯的实用增强型通证协议.pdf

readme.md

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 {
public:
    example(account_name self):
            contract(self)
    {};
    void consume(account_name from, asset quantity, string memo);
    void receipt(account_name from, asset quantity);
};

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

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

    // TODO: your business logic

    action(
            permission_level{_self, N(active)},
            _self,
            N(receipt),
            make_tuple(from, quantity)
    ).send();
}

void example::receipt(account_name from, asset quantity) {
    require_auth(_self);
}

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);
            return;
        }

        if (code != receiver) return;

        switch (action) {
            EOSIO_API(example, (receipt))
        };
        eosio_exit(0);
    }
}

Token Exchange

tokenpocket

bitportal

51token

Block Explorer

eospark

eosflare

You can’t perform that action at this time.