I used the official code to create a token contract,and I created a new contract. Now I hope to use this new contract to invoke token contract, transfer token from A account to B account, and encounter the problem of no transferable quota.
pragma solidity ^0.4.17;
interface Token {
function approve(address spender, uint256 value) public returns (bool);
function transferFrom(address from, address to, uint256 value) public returns (bool);
}
/**
* The TrxCoin contract does this and that...
*/
contract TrxCoin {
Token token = Token(0xAc08fe3C9F442990C52904dE997D9972499bD3E6);
function getContractAddr() view public returns (address) {
return this;
}
function approve(address spender, uint256 value) public {
require(token.approve(spender, value));
}
function transfer(address _to, uint value) public payable {
require(token.transferFrom(msg.sender, _to, value));
}
}
When I use the token contract to call the approve method directly, I can transfer through the new contract, but I can't allocate the quota directly by calling the approve method with the new contract.
Why is this? Thank you for the answer!