Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ethereum TypeError:[msg.sender]=totalSupply的变量查找平衡后未找到匹配声明__Ethereum_Solidity_Smartcontracts_Remix - Fatal编程技术网

Ethereum TypeError:[msg.sender]=totalSupply的变量查找平衡后未找到匹配声明_

Ethereum TypeError:[msg.sender]=totalSupply的变量查找平衡后未找到匹配声明_,ethereum,solidity,smartcontracts,remix,Ethereum,Solidity,Smartcontracts,Remix,因此,我使用Openzepplin solidity合同的组合来创建一个供应上限为3000万的可燃代币。 我在上一份合同中不断出现上述错误,我不知道为什么。我尝试用余额[msg.sender]替换余额[msg.sender],用totalSupply替换totalSupply,并在本地合同中重新声明存在公共uint256(尽管它应该被继承) 以下是我与所有依赖项的扁平化合同(感谢您的帮助!): pragma-solidity^0.4.24; //文件:contracts\token\ERC20\

因此,我使用Openzepplin solidity合同的组合来创建一个供应上限为3000万的可燃代币。 我在上一份合同中不断出现上述错误,我不知道为什么。我尝试用余额[msg.sender]替换余额[msg.sender],用totalSupply替换totalSupply,并在本地合同中重新声明存在公共uint256(尽管它应该被继承)

以下是我与所有依赖项的扁平化合同(感谢您的帮助!):

pragma-solidity^0.4.24;
//文件:contracts\token\ERC20\ERC20.sol
/**
*@title ERC20接口
*@dev-seehttps://github.com/ethereum/EIPs/issues/20
*/
合同ERC20{
函数totalSupply()公共视图返回(uint256);
(地址)公共视图返回的功能平衡(uint256);
功能津贴(地址\所有者、地址\支出者)
公共视图返回(uint256);
函数传输(地址_至,uint256 _值)公共返回(bool);
功能批准(地址_消费者,uint256 _值)
公众申报表(bool);
函数transferFrom(地址_from,地址_to,uint256 _值)
公众申报表(bool);
事件转移(
从中索引的地址,
索引到的地址,
uint256值
);
活动批准(
地址索引所有者,
地址索引挥霍者,
uint256值
);
}
//文件:contracts\math\SafeMath.sol
/**
*@title SafeMath
*@dev Math操作,安全检查在出错时恢复
*/
图书馆安全数学{
/**
*@dev乘以两个数字,溢出时恢复。
*/
函数mul(uint256\u a,uint256\u b)内部纯返回(uint256){
//气体优化:这比要求“a”不为零更便宜,但是
//如果还测试了“b”,则福利将丢失。
//见:https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
如果(_a==0){
返回0;
}
uint256 c=_a*_b;
要求(c/_a==_b);
返回c;
}
/**
*@dev整数除以截断商的两个数字,再除以零。
*/
函数div(uint256\u a,uint256\u b)内部纯返回(uint256){
require(_b>0);//仅当除以0时,Solidity才会自动断言
uint256 c=_a/_b;
//assert(_a==_b*c+_a%_b);//在任何情况下都是这样
返回c;
}
/**
*@dev减去两个数字,溢出时恢复(即,如果减数大于分钟数)。
*/
函数子(uint256\u a,uint256\u b)内部纯返回(uint256){
需要(_b=_a);
返回c;
}
/**
*@dev将两个数字相除并返回余数(无符号整数模),
*除以零时恢复。
*/
函数mod(uint256 a,uint256 b)内部纯返回(uint256){
要求(b!=0);
返回%b;
}
}
//文件:contracts\token\ERC20\StandardToken.sol
/**
*@title标准ERC20令牌
*
*@dev基本标准令牌的实现。
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
*根据FirstBlood的代码:https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
合同标准令牌是ERC20{
对uint256使用SafeMath;
映射(地址=>uint256)私人余额;
允许私有映射(地址=>mapping(地址=>uint256));
uint256公共总供给;
/**
*@dev存在的令牌总数
*/
函数totalSupply()公共视图返回(uint256){
返回总供给;
}
/**
*@dev获取指定地址的余额。
*@param_owner查询余额的地址。
*@返回一个uint256,表示传递的地址所拥有的金额。
*/
(地址所有者)公共视图返回的功能平衡(uint256){
返还余额[_所有者];
}
/**
*@dev函数检查所有者允许挥霍者使用的代币数量。
*@param_owner address拥有资金的地址。
*@param_spender地址将花费资金的地址。
*@返回一个uint256,指定仍可供挥霍者使用的代币数量。
*/
功能余量(
地址(业主),
地址
)
公众的
看法
返回(uint256)
{
允许退货[\u所有者][\u消费者];
}
/**
*@dev指定地址的传输令牌
*@param_到要传输到的地址。
*@param\u表示要转移的金额。
*/
函数传输(地址到,uint256值)公共返回(bool){
要求(_值_金额);
//应该https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 被接受,,
//此函数需要发出具有更新批准的事件。
允许的[\u账户][msg.sender]=允许的[\u账户][msg.sender].子账户(\u金额);
_烧钱(_账户,_金额);
}
}
//文件:contracts\token\ERC20\BurnableToken.sol
/**
*@title可燃令牌
*@dev令牌,可以不可逆转地烧毁(销毁)。
*/
契约BurnableToken是StandardToken{
事件燃烧(地址索引燃烧器,uint256值);
/**
*@dev会燃烧一定数量的代币。
*@param\u表示要燃烧的令牌数量。
*/
功能燃烧(uint256_值)公共{
_烧录(msg.sender,_值);
}
/**
*@dev从目标地址燃烧特定数量的令牌,并减少容差
*@param\u from address您要从中发送令牌的地址
*@param_value uint256要燃烧的令牌量
*/
函数burnFrom(地址_from,uint256 _值)公共{
_burnFrom(_from,_值);
}
/**
*@dev覆盖StandardToken.\u burn以使burn和burnFrom发出
*另一个烧伤事件。
*/
函数(地址、用户、uint256值)内部{
超级。_burn(_who,_value);
发出烧伤(_who,_value);
}
}
/**
*@title KWATT_令牌
*@dev令牌,可以不可逆转地烧毁(销毁)。
*/
合同KWATT_代币被烧掉了
pragma solidity ^0.4.24;

// File: contracts\token\ERC20\ERC20.sol

/**
 * @title ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/20
 */
contract ERC20 {
  function totalSupply() public view returns (uint256);

  function balanceOf(address _who) public view returns (uint256);

  function allowance(address _owner, address _spender)
    public view returns (uint256);

  function transfer(address _to, uint256 _value) public returns (bool);

  function approve(address _spender, uint256 _value)
    public returns (bool);

  function transferFrom(address _from, address _to, uint256 _value)
    public returns (bool);

  event Transfer(
    address indexed from,
    address indexed to,
    uint256 value
  );

  event Approval(
    address indexed owner,
    address indexed spender,
    uint256 value
  );
}

// File: contracts\math\SafeMath.sol

/**
 * @title SafeMath
 * @dev Math operations with safety checks that revert on error
 */
library SafeMath {

  /**
  * @dev Multiplies two numbers, reverts on overflow.
  */
  function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
    // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
    // benefit is lost if 'b' is also tested.
    // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
    if (_a == 0) {
      return 0;
    }

    uint256 c = _a * _b;
    require(c / _a == _b);

    return c;
  }

  /**
  * @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
  */
  function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
    require(_b > 0); // Solidity only automatically asserts when dividing by 0
    uint256 c = _a / _b;
    // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold

    return c;
  }

  /**
  * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
  */
  function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
    require(_b <= _a);
    uint256 c = _a - _b;

    return c;
  }

  /**
  * @dev Adds two numbers, reverts on overflow.
  */
  function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
    uint256 c = _a + _b;
    require(c >= _a);

    return c;
  }

  /**
  * @dev Divides two numbers and returns the remainder (unsigned integer modulo),
  * reverts when dividing by zero.
  */
  function mod(uint256 a, uint256 b) internal pure returns (uint256) {
    require(b != 0);
    return a % b;
  }
}

// File: contracts\token\ERC20\StandardToken.sol

/**
 * @title Standard ERC20 token
 *
 * @dev Implementation of the basic standard token.
 * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
 * Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
 */
contract StandardToken is ERC20 {
  using SafeMath for uint256;

  mapping (address => uint256) private balances;

  mapping (address => mapping (address => uint256)) private allowed;

  uint256 public totalSupply_;

  /**
  * @dev Total number of tokens in existence
  */
  function totalSupply() public view returns (uint256) {
    return totalSupply_;
  }

  /**
  * @dev Gets the balance of the specified address.
  * @param _owner The address to query the the balance of.
  * @return An uint256 representing the amount owned by the passed address.
  */
  function balanceOf(address _owner) public view returns (uint256) {
    return balances[_owner];
  }

  /**
   * @dev Function to check the amount of tokens that an owner allowed to a spender.
   * @param _owner address The address which owns the funds.
   * @param _spender address The address which will spend the funds.
   * @return A uint256 specifying the amount of tokens still available for the spender.
   */
  function allowance(
    address _owner,
    address _spender
   )
    public
    view
    returns (uint256)
  {
    return allowed[_owner][_spender];
  }

  /**
  * @dev Transfer token for a specified address
  * @param _to The address to transfer to.
  * @param _value The amount to be transferred.
  */
  function transfer(address _to, uint256 _value) public returns (bool) {
    require(_value <= balances[msg.sender]);
    require(_to != address(0));

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

  /**
   * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
   * Beware that changing an allowance with this method brings the risk that someone may use both the old
   * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
   * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
   * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
   * @param _spender The address which will spend the funds.
   * @param _value The amount of tokens to be spent.
   */
  function approve(address _spender, uint256 _value) public returns (bool) {
    allowed[msg.sender][_spender] = _value;
    emit Approval(msg.sender, _spender, _value);
    return true;
  }

  /**
   * @dev Transfer tokens from one address to another
   * @param _from address The address which you want to send tokens from
   * @param _to address The address which you want to transfer to
   * @param _value uint256 the amount of tokens to be transferred
   */
  function transferFrom(
    address _from,
    address _to,
    uint256 _value
  )
    public
    returns (bool)
  {
    require(_value <= balances[_from]);
    require(_value <= allowed[_from][msg.sender]);
    require(_to != address(0));

    balances[_from] = balances[_from].sub(_value);
    balances[_to] = balances[_to].add(_value);
    allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
    emit Transfer(_from, _to, _value);
    return true;
  }

  /**
   * @dev Increase the amount of tokens that an owner allowed to a spender.
   * approve should be called when allowed[_spender] == 0. To increment
   * allowed value is better to use this function to avoid 2 calls (and wait until
   * the first transaction is mined)
   * From MonolithDAO Token.sol
   * @param _spender The address which will spend the funds.
   * @param _addedValue The amount of tokens to increase the allowance by.
   */
  function increaseApproval(
    address _spender,
    uint256 _addedValue
  )
    public
    returns (bool)
  {
    allowed[msg.sender][_spender] = (
      allowed[msg.sender][_spender].add(_addedValue));
    emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
    return true;
  }

  /**
   * @dev Decrease the amount of tokens that an owner allowed to a spender.
   * approve should be called when allowed[_spender] == 0. To decrement
   * allowed value is better to use this function to avoid 2 calls (and wait until
   * the first transaction is mined)
   * From MonolithDAO Token.sol
   * @param _spender The address which will spend the funds.
   * @param _subtractedValue The amount of tokens to decrease the allowance by.
   */
  function decreaseApproval(
    address _spender,
    uint256 _subtractedValue
  )
    public
    returns (bool)
  {
    uint256 oldValue = allowed[msg.sender][_spender];
    if (_subtractedValue >= oldValue) {
      allowed[msg.sender][_spender] = 0;
    } else {
      allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
    }
    emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
    return true;
  }

  /**
   * @dev Internal function that mints an amount of the token and assigns it to
   * an account. This encapsulates the modification of balances such that the
   * proper events are emitted.
   * @param _account The account that will receive the created tokens.
   * @param _amount The amount that will be created.
   */
  function _mint(address _account, uint256 _amount) internal {
    require(_account != 0);
    totalSupply_ = totalSupply_.add(_amount);
    balances[_account] = balances[_account].add(_amount);
    emit Transfer(address(0), _account, _amount);
  }

  /**
   * @dev Internal function that burns an amount of the token of a given
   * account.
   * @param _account The account whose tokens will be burnt.
   * @param _amount The amount that will be burnt.
   */
  function _burn(address _account, uint256 _amount) internal {
    require(_account != 0);
    require(balances[_account] > _amount);

    totalSupply_ = totalSupply_.sub(_amount);
    balances[_account] = balances[_account].sub(_amount);
    emit Transfer(_account, address(0), _amount);
  }

  /**
   * @dev Internal function that burns an amount of the token of a given
   * account, deducting from the sender's allowance for said account. Uses the
   * internal _burn function.
   * @param _account The account whose tokens will be burnt.
   * @param _amount The amount that will be burnt.
   */
  function _burnFrom(address _account, uint256 _amount) internal {
    require(allowed[_account][msg.sender] > _amount);

    // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
    // this function needs to emit an event with the updated approval.
    allowed[_account][msg.sender] = allowed[_account][msg.sender].sub(_amount);
    _burn(_account, _amount);
  }
}

// File: contracts\token\ERC20\BurnableToken.sol

/**
 * @title Burnable Token
 * @dev Token that can be irreversibly burned (destroyed).
 */
contract BurnableToken is StandardToken {

  event Burn(address indexed burner, uint256 value);

  /**
   * @dev Burns a specific amount of tokens.
   * @param _value The amount of token to be burned.
   */
  function burn(uint256 _value) public {
    _burn(msg.sender, _value);
  }

  /**
   * @dev Burns a specific amount of tokens from the target address and decrements allowance
   * @param _from address The address which you want to send tokens from
   * @param _value uint256 The amount of token to be burned
   */
  function burnFrom(address _from, uint256 _value) public {
    _burnFrom(_from, _value);
  }

  /**
   * @dev Overrides StandardToken._burn in order for burn and burnFrom to emit
   * an additional Burn event.
   */
  function _burn(address _who, uint256 _value) internal {
    super._burn(_who, _value);
    emit Burn(_who, _value);
  }
}
/**
 * @title KWATT_Token Token
 * @dev Token that can be irreversibly burned (destroyed).
 */
contract KWATT_Token is BurnableToken {
    string public name = "Token";
    string public symbol = "TKN";
    uint8 public decimals = 18;
    uint public INITIAL_SUPPLY = 300000000;
constructor() public {
  totalSupply_ = INITIAL_SUPPLY;
  balanceOf[msg.sender] = totalSupply_;
}

}