GithubHelp home page GithubHelp logo

starit / tokendapppub Goto Github PK

View Code? Open in Web Editor NEW

This project forked from debankdefi/tokendapppub

0.0 2.0 0.0 3.15 MB

a Bancor based utility-enhanced token protocol

Home Page: https://dapp.pub

CMake 8.12% C++ 91.88%

tokendapppub's Introduction

tokendapppub

tokendapppub: a bancor based utility-enhanced token protocol

Usage (buy,sell,transfer,publish)

Visit https://dapp.pub and buy 100.0000 PUB, publish your DApp token by yourself. And then, you can buy/sell and transfer your token on the website.

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

Partners

tokenpocket eospark eosflare

tokendapppub's People

Contributors

thbourlove avatar

Watchers

James Cloos avatar Jamie C 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.