1

don't know if someone can help me, but let me explain my problem. For more transparency in my ERC20 token generation smart contract, I want to hardcode the Team Pool (0xA) and Crowdfunding Pool (0xB) with allocation amounts, just as example.

constructor() public {
    symbol = "STT";
    name = "Sample Token";
    decimals = 18; 

    totalSupply_ = 500000000 * (10 ** uint256(decimals));
    // Now we need to split the total supply into 2 hardcoded addresses
}

//my pseudo code idea 
function allocate() public {
    allocations[0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA] = 250000000 * (10 ** uint256(decimals));
    allocations[0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB] = 250000000 * (10 ** uint256(decimals)); 
}

Means that after deployment the total supply will be distributed to two ethereum addresses.

Can someone guide me, please and how the amounts are send while deployment. ? The rest of the code is based on https://github.com/OpenZeppelin/openzeppelin-solidity BasicToken without mint or burn

Thanks in advance

Cheers

contract SampleToken is PausableToken {
    string public constant name = "Sample Token"; 
    string public constant symbol = "STT";
    uint256 public constant decimals = 18;

    mapping (address => uint256) freezes;

    /* This notifies clients about the amount burnt */
    event Burn(address indexed from, uint256 value);

    /* This notifies clients about the amount frozen */
    event Freeze(address indexed from, uint256 value);

    /* This notifies clients about the amount unfrozen */
    event Unfreeze(address indexed from, uint256 value);

    constructor() public {
        totalSupply_ = 500000000 * (10 ** uint256(decimals));
        balances[msg.sender] = totalSupply_;
        // we need to split the total supply to two or more addresses 
    }

    function freezeOf(address _owner) public view returns (uint256) {
        return freezes[_owner];
    }

    function burn(uint256 _value) whenNotPaused public returns (bool) {
        require(_value <= balances[msg.sender]);

        balances[msg.sender] = balances[msg.sender].sub(_value);
        totalSupply_ = totalSupply_.sub(_value);
        emit Burn(msg.sender, _value);
        return true;
    }

    function freeze(uint256 _value) whenNotPaused public returns (bool) {
        require(_value <= balances[msg.sender]);

        balances[msg.sender] = balances[msg.sender].sub(_value);
        freezes[msg.sender] = freezes[msg.sender].add(_value);
        emit Freeze(msg.sender, _value);
        return true;
    }

    function unfreeze(uint256 _value) whenNotPaused public returns (bool) {
        require(_value <= freezes[msg.sender]);

        freezes[msg.sender] = freezes[msg.sender].sub(_value);
        balances[msg.sender] = balances[msg.sender].add(_value);
        emit Unfreeze(msg.sender, _value);
        return true;
    }

    /**
    * @dev Allows the current owner to transfer control of the contract to a newOwner.
    * @param newOwner The address to transfer ownership to.
    */
    function transferOwnership(address newOwner) onlyOwner whenNotPaused public {
        super.transferOwnership(newOwner);
    }

    /**
    * The fallback function.
    */
    function() payable external {
        revert();
    }
}
4
  • If you need more information let me know.
    – eonic
    Commented Feb 15, 2019 at 18:51
  • can you provide you current attempts? I mean you contract Commented Feb 15, 2019 at 18:59
  • Without more details from your contract (like the name of variables used) is hard to say something useful. For example if you use OpenZeppelin contracts you need something like _mint(0xAAAAA..A, INITIAL_SUPPLY/2); _mint(0xBBBBB..B, INITIAL_SUPPLY/2).
    – Ismael
    Commented Feb 16, 2019 at 5:44
  • Seems like a hard problem or does it need more information ? 500000000 is my custom ERC20 Token total and I want to split them between 3 accounts. for example 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA = 200000000 0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB = 200000000 0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC = 100000000 means 3 ethereum accounts
    – eonic
    Commented Feb 21, 2019 at 21:06

2 Answers 2

0

From the question it is not clear what is required.

Following is a very basic contract that requires 1 ether to deploy. Then splits that ether between 2 addresses evenly upon calling allocate by the owner.

pragma solidity >=0.5.4 <0.6.0;

contract SplitSupply {
    address owner;
    address payable private team = 0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C;
    address payable private crowd = 0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB;

    constructor() payable public {
        require(1 ether < msg.value);
        owner = msg.sender;
    }

    function allocate() public {
        require(msg.sender == owner);
        address(team).transfer(address(this).balance / 2);
        address(crowd).transfer(address(this).balance);
    }
}
11
  • It’s a Token, I’ve edit my question
    – eonic
    Commented Feb 16, 2019 at 8:16
  • not really what i'm looking for
    – eonic
    Commented Feb 18, 2019 at 8:22
  • Let's start over again. You want to deploy such a contract that will receive some value in constructor. You save that in totalSupply_. Then it get a bit fuzzy for me. Do you want to send half of totalSupply_ to an account and other half to another account? Commented Feb 18, 2019 at 9:27
  • Hey Thanks for your reply, correct but I want to display the token amounts in numbers like in my case 250000000 * (10 ** uint256(decimals)) and not /2 send to two separate addresses
    – eonic
    Commented Feb 18, 2019 at 9:34
  • Is that something where you can help ?
    – eonic
    Commented Feb 18, 2019 at 12:00
0

In the constructor, just replace the line that says

balances[msg.sender] = totalSupply

with something like

balances[0xA] = 250000000 * 10 ** 18;
balances[0xB] = 250000000 * 10 ** 18;

(where 0xA and 0xB are your 2 hardcoded addresses).

That way on deployment, both 0xA and 0xB start with 250 million.

By the way, you can also write

balances[0xA] = 250000000 ether;
balances[0xB] = 250000000 ether;

it's equivalent

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.