【问题标题】:Ethereum contract do not change it state while minting以太坊合约在铸造时不会改变它的状态
【发布时间】:2018-04-03 18:53:58
【问题描述】:

有sol合约函数mint():

 function mint(address _holder, uint _value) external {
require(msg.sender == ico);
require(_value != 0);
require(totalSupply + _value <= TOKEN_LIMIT);

balances[_holder] += _value;
totalSupply += _value;
Transfer(0x0, _holder, _value);  }

我成功地调用了这个函数来创建 10000 个令牌并将它们发送到 eth.accounts[0]:

personal.unlockAccount(eth.accounts[0])

是的

minedContract.mint.sendTransaction(eth.accounts[0], 10000, {from:eth.accounts[0]})

“0x6e4474072ebf2836fa6b737a6341504f79b53417e366c742c7ffefa0f3aff832”

但是 eth.accounts[0] 的余额仍然是 0。合约的总余额也是 0。我一直等到它被开采。 为什么合同状态没有改变?

【问题讨论】:

  • 余额如何查询?
  • minedContract.balanceOf(eth.accounts[0])
  • 你能分享balanceOf的代码吗?还有,交易真的成功了吗? (也许它正在被还原......例如也许msg.sender != ico。)
  • 只是 BaseToken 方法:function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; }
  • 交易成功。

标签: ethereum abi smartcontracts go-ethereum


【解决方案1】:

我已经重复了自己的步骤来重现上述行为,但失败了,因为一切正常。由于人为因素而关闭。

【讨论】:

    猜你喜欢
    • 2016-02-28
    • 2019-04-07
    • 2018-03-15
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 2018-08-27
    • 2019-12-11
    • 2019-05-09
    相关资源
    最近更新 更多