I'll start by saying that I'm a newbie. I'm learning Solidity and how Smart Contracts work. What I would like to do is simple: I would like to sell MyFriendToken (MFT) to friends only, in exchange for some ETH (1 ETH = 1000 MFT), and then allow them to trade this token with other currencies or other tokens (maybe through EtherDelta).

Here is the simple contract about to my two questions (further below) refer:

pragma solidity ^0.4.0;
contract ERC20 {
    //here are the same functions defined in the TokenContractFragment

    function balanceOf(address _owner) constant returns (uint balance);
    function transfer(address _to, uint _value) returns (bool success);
    function transferFrom(address _from, address _to, uint _value) returns (bool success);
    function approve(address _spender, uint _value) returns (bool success);
    function allowance(address _owner, address _spender) constant returns (uint remaining);
    event Transfer(address indexed _from, address indexed _to, uint _value);
    event Approval(address indexed _owner, address indexed _spender, uint _value);
    uint public totalSupply = 0;
    mapping(address => uint256) balances;

contract MyFriendToken is ERC20{
    string public token_name;
    string public symbol;
    uint8 public decimals;

    address public owner;

    bool purchase_OK = true;

    address friend1 = address(0x123...);
    address friend2 = address(0x456...);

    function purchase_ko() {
        if(msg.sender != owner){ throw;}
        purchase_OK = false;

    function purchase_ok()  {
        if(msg.sender != owner){ throw;}
        purchase_OK = true;

    function MyFriendToken(){

        owner = msg.sender;
        token_name = "MyFriendToken";
        symbol = "MFT";
        decimals = 18;

    function kill() {
        if (msg.sender == owner) selfdestruct(owner);

    function() payable {
        if(msg.sender != friend1 && msg.sender != friend2) {throw;}

        uint256 myFriendToken = (msg.value * 1000);
        totalSupply += myFriendToken;
        balances[msg.sender] += myFriendToken;

Here are my questions:

1) When the purchase ends, can my friends exchange this token on EtherDelta, for instance?

2) If I call the kill() function, will all the balance of my friends be lost?

Many thanks. If this question is too broad or if this isn't the right place, I'll delete without problem.

1 Answer 1


1- I think to add your token into Etherdelta you need to get in touch with them at https://gitter.im/etherdelta/etherdelta.github.io

2- as stated in the official documentation :

Ether stored at that address is sent to a designated target and then the storage and code is removed from the state

so your friends balances will be lost (you won't know what is the balance of the address X) but the whole amount will be sent to the owner address.

  • Let me make sure I got. If I call the selfdestruct function, all the ether sent to the contract will be sent to the contract owner, instead all the my friends' token balance will be lost; so in this way they lost their tokens?
    – d3llafr33
    Jul 11, 2017 at 23:42
  • their tokens are only the amount saved in the balance mapping( mapping(address => uint256) balances; ). so it's only a value stored in this mapping therefore when the states are "erased" using selfdestructthey will lose their tokens. you could reimburse your users in your kill function before calling selfdestruct.
    – Badr Bellaj
    Jul 11, 2017 at 23:46
  • oh great. Now it's all clear. Thank you for your prompt reply.
    – d3llafr33
    Jul 11, 2017 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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