Skip to main content
6 of 7
added 6 characters in body; edited title
eonic
  • 11
  • 4

Initial ERC20 Token supply split into 2 or more hardcoded addresses

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();
    }
}
eonic
  • 11
  • 4