[英]Call function on another contract failed
I'm studying solidity. 我正在研究稳固性。
TT3 token generation on test net is no problem, but TT3Token_Test failed. 在测试网络上生成TT3令牌没有问题,但是TT3Token_Test失败。 (TT3Token and TT3Token_Test have been deployed to the same wallet address)
(TT3Token和TT3Token_Test已部署到相同的钱包地址)
https://ropsten.etherscan.io/tx/0x4099019ecc47640dc7d3ceb3de3d50759f4e5ebc6d730410cda992c97d78ea10 https://ropsten.etherscan.io/tx/0x4099019ecc47640dc7d3ceb3de3d50759f4e5ebc6d730410cda992c97d78ea10
I do not know why not. 我不知道为什么不这样做。
(I deployed it to ropsten using remix) (我将它部署到使用remix的罗普森)
pragma solidity ^0.4.23;
import "./StandardToken.sol"; // openzeppelin
contract TT3Token is StandardToken {
string public constant name = "TT3Token";
string public constant symbol = "TT3";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals));
constructor() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
function sendTest(address _to, uint256 _value) public {
transfer(_to, _value);
}
}
contract TT3Token_Test {
constructor() public {
address r = 0xEcA254594c5bBCCEBc321e9252cc886cE37Be914;
TT3Token token = TT3Token(msg.sender);
token.sendTest(r, 99 * (10 ** uint256(18)));
}
}
TT3Token token = TT3Token(msg.sender)
doesn't make sense unless it's the TT3Token
contract itself that is creating a new TT3Token_Test
deployment (which is not shown in your code). 除非是
TT3Token
合同本身创建了一个新的TT3Token_Test
部署(代码中未显示),否则TT3Token token = TT3Token(msg.sender)
意义。 msg.sender
is the address from which the transaction was initiated from (an EOA account). msg.sender
是从中启动交易的地址(一个EOA帐户)。 It should be the address of your deployed TT3Token
contract. 它应该是您部署的
TT3Token
合同的地址。
Also, the tokens are owned by the address that deployed the TT3Token
contract. 同样,令牌由部署
TT3Token
合同的地址拥有。 You need to transfer tokens from that same account to the TT3Token_Test
address in order for the call to sendTest
to succeed. 你需要从同一个帐户转移令牌到
TT3Token_Test
为了地址调用sendTest
成功。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.