0

I have deployed a regular ERC20-compliant token contract through the Remix compiler and MetaMask. After doing so, the deployed token shows up on Etherscan as a token. However, when I try to deploy a token contract that is owned, it requires me to deploy the token contract and the owner contract separately, resulting in two isolated contracts that are from the same source code.

I use the very simple contract code from the official Ethereum website: https://ethereum.org/token#full-coin-code

Any help you be appreciated

3

You don't need to deploy the inherited contract (owned) separately, you just need to inherit it in your token contract by adding in "is owned" (example below).

Some more information about inheritance here. http://solidity.readthedocs.io/en/develop/contracts.html#inheritance

pragma solidity ^0.4.18;

contract owned {
    function owned() { owner = msg.sender; }
    address owner;
}


// Use "is" to derive from another contract. Derived
// contracts can access all non-private members including
// internal functions and state variables. These cannot be
// accessed externally via `this`, though.
contract MyToken is owned {
    function kill() {
        if (msg.sender == owner) selfdestruct(owner);
    }
}

Then in Remix, you can choose to deploy MyToken only. Since the contract source code refers to owned ("is owned"), the owned code will be included in the compiled MyToken code.

Deploy MyToken only: Deploy MyToken only

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.