2

tokens like TAAS or Bancor have their functionalities, but the are somehow splitted into several different smart contracts?

One of them: https://etherscan.io/token/0x2e9e055d25530f7b3365e89c45bab1a1441159b4

I've the following question about Ethereum smart contracts:

  1. Do I understand correctly that it is possible to "interlink" smart contracts? In this case it means: That the usual tradeable smart contract is just a "dumb coin" contract and all the functionality of the token is run on a seperate smart contract, like distribution of dividend?

  2. How can they mask the smart contract so its not possible to see the code of the contract (see the link above).

Thank you greetings!

1

You have 1) pretty much correct. Just set an address on the Dispatcher contract to a token that has the functionality, now you have a front-facing upgradable interface. Delete all calls back to that contract from the Dispatcher, which faces the public. Separate the data to another contract and add it to the functionality token contract, now you have the data separated for easy upgrade/bug fix.

They can mask the smart contract by not verifying on Etherscan.

They set the address in their dispatcher contract. The disaptcher is one you linked me to. In the "read smart contract" section, you can see a "etoken2" and it's set to an address.

What the dispatcher does is forward all calls to etoken2, as described in TAAS's model here: https://github.com/bokkypoobah/TokenTrader/wiki/TAAS-%E2%80%90-Token-as-a-Service (search for this line that describes the implementation: EToken2 Asset Proxy)

Now, the EToken2 is the code with all the functions. So instead of the main Dispatcher contract having transfer function that goes like balances[_to] += _amount and such, the dispatcher contract has a function that is like e2token.transfer(msg.value, msg.sender) or e2token.delegatecall.transfer(). In this way, anyone who hits the dispatcher, gets their call redirected to the token.

I set the address of the etoken on my dispatcher. If I want to upgrade it, I deploy a new etoken instance, and call a setEtokenAddress (or something like it) function on my dispatcher, and now it knows the new address, and forwards the calls there.

This contract, however, is not upgradable. Notice the init() method:

**

* Sets EToken2 address, assigns symbol and name.
 *
 * Can be set only once.
 *
 * @param _etoken2 EToken2 contract address.
 * @param _symbol assigned symbol.
 * @param _name assigned name.
 *
 * @return success.
 */
function init(EToken2 _etoken2, string _symbol, string _name) returns(bool) {
    if (address(etoken2) != 0x0) {
        return false;
    }
    etoken2 = _etoken2;
    etoken2Symbol = _bytes32(_symbol);
    name = _name;
    symbol = _symbol;
    return true;
}

We can see we set the etoken, and we can only do it once.

Now lets look at how we get the total supply from the TAAS contract:

/**
     * Returns asset total supply.
     *
     * @return asset total supply.
     */
    function totalSupply() constant returns(uint) {
        return etoken2.totalSupply(etoken2Symbol);
    }

Simply calls back to the etoken2 like described before.

  • Thank you for the superb answer! But I didn't really get the code stuff at the contract of TAAS for example which place do you exactly mean where they "interlink" the contracts?! etherscan.io/token/TAAS – Croin Aug 13 '17 at 16:44
  • I edited my post w/ a more detailed explanation of how TAAS does it. – diabetesjones Aug 13 '17 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.