I have an ERC20 token I'm working on, and I want it to update the total supply with the world population. Using this API: https://world-population.p.rapidapi.com/worldpopulation, what code will allow me to update my balance with the world population? The token is not already deployed

My code:

pragma solidity ^0.4.21;

import "./EIP20Interface.sol";

contract Helius is EIP20Interface {

    uint256 constant private MAX_UINT256 = 2**256 - 1;
    mapping (address => uint256) public balances;
    mapping (address => mapping (address => uint256)) public allowed;

    string public name;                  
    uint8 public decimals;                
    string public symbol;                 

    function Helius(
        uint256 _initialAmount,
        string _tokenName,
        uint8 _decimalUnits,
        string _tokenSymbol
    ) public {
        balances[msg.sender] = _initialAmount;
        totalSupply = _initialAmount;                       
        name = _tokenName;                                  
        decimals = _decimalUnits;                           
        symbol = _tokenSymbol;              

    function transfer(address _to, uint256 _value) public returns (bool success) {
        require(balances[msg.sender] >= _value);
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        emit Transfer(msg.sender, _to, _value);
        return true;

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        uint256 allowance = allowed[_from][msg.sender];
        require(balances[_from] >= _value && allowance >= _value);
        balances[_to] += _value;
        balances[_from] -= _value;
        if (allowance < MAX_UINT256) {
            allowed[_from][msg.sender] -= _value;
        emit Transfer(_from, _to, _value);
        return true;

    function balanceOf(address _owner) public view returns (uint256 balance) {
        return balances[_owner];

    function approve(address _spender, uint256 _value) public returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;

    function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
        return allowed[_owner][_spender];
New contributor
Henry Bass is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Is the token already deployed? Or are you looking to extend the code before deployment, in order to allow yourself to increase the total supply? – goodvibration Nov 21 at 17:22
  • And what do you mean "update the total supply with the world population" anyway? Do you want to update it every once in a while? Or only one time upon deployment? Do you realize that updating the total supply means printing more tokens, which technically means inflation (which means that the effective equity of each one of your holders will decrease every time you increase the total supply)? – goodvibration Nov 21 at 17:25
  • Following your update (The token is not already deployed) - your question is completely unclear. The total supply is set according to the first input parameter that you pass upon deployment. This is actually pretty clear in your code (assuming that you can actually read it). What more do you need??? – goodvibration Nov 21 at 17:27

Browse other questions tagged or ask your own question.