在Remix - Solidity IDE中,如何传递参数?

时间:2018-04-28 09:49:40

标签: solidity remix

我正在研究稳固的智能合约,但我遇到了一个问题。每次我试图创建这份合同时,我的论点都没有得到证实。

我期待一个" OreOreCoin"当我选择名字时出来,但我得到一个空字符串。

enter image description here

enter image description here

这是我的代码:

pragma solidity ^0.4.8;

contract OreOreCoin{
    string public name;
    string public symbol;
    uint8 public decimals;
    uint256 public totalSupply;

    mapping (address => uint256) public balanceOf;

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

    function OreOreCoin(uint256 _supply, string _name, string _symbol, uint8 
    _demicals){
        balanceOf[msg.sender] = _supply;
        name = _name;
        symbol = _symbol;
        decimals = _demicals;
        totalSupply = _supply;
    }

    function transfer(address _to, uint256 _value){
        if(balanceOf[msg.sender] < _value) throw;
        if(balanceOf[_to] + _value < balanceOf[_to]) throw;
        balanceOf[msg.sender] -= _value;
        balanceOf[_to] += _value;

        Transfer(msg.sender,_to,_value);
    }
}

可能是什么问题?

1 个答案:

答案 0 :(得分:1)

不要引用整个参数列表。在这样做时,您将一个字符串参数发送到构造函数中,该构造函数转换为uint256 _supply,其余的都是默认值。您可以通过在Remix UI中查看事务的详细信息来确认这一点。

enter image description here

参数列表应该是:

10000,”OreOreCoin”,”oc”,0