0

I'm studying solidity.

TT3 token generation on test net is no problem, but TT3Token_Test failed. (TT3Token and TT3Token_Test have been deployed to the same wallet address)

https://ropsten.etherscan.io/tx/0x4099019ecc47640dc7d3ceb3de3d50759f4e5ebc6d730410cda992c97d78ea10

I do not know why not.

(I deployed it to ropsten using 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)));
    }
}
Kidong
  • 1
  • 1

1 Answers1

1

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). msg.sender is the address from which the transaction was initiated from (an EOA account). It should be the address of your deployed TT3Token contract.

Also, the tokens are owned by the address that deployed the TT3Token contract. You need to transfer tokens from that same account to the TT3Token_Test address in order for the call to sendTest to succeed.

Adam Kipnis
  • 10,175
  • 10
  • 35
  • 48
  • TT3Token and TT3Token_Test have been deployed to the same wallet address. – Kidong May 21 '18 at 21:45
  • Does the owner of the TT3 token fail to call sendTest from TT3Token_Test? – Kidong May 21 '18 at 21:50
  • Right now, the code, as posted, is failing because there is no `sendTest` method on the address represented by `msg.sender`. That is the address of your wallet, not the address of the deployed contract. – Adam Kipnis May 21 '18 at 22:15