I have deployed contract A. Now I am creating gateway contract B and I want to send some tokens of contract A to user address X using owner address. Worth to mention that contract A owner is the same as contract B. I do the following
contract A is Ownable { // this one already deployed by owner
constructor() {
owner = msg.sender; // owner address is 0x123
approve(msg.sender, totalSupply); // let's approve all tokens for owner
}
function transferFrom(address from, address to, uint256 value) public returns (bool) {
require(value <= allowed[from][msg.sender], "Not allowed!");
// let's skip other logic
}
}
contract B is Ownable { // gateway contract will be deployed and executed by same owner
A contractA = ETC20(0x111);
address payable X = 0x333;
constructor() {
owner = msg.sender; // owner address is 0x123
}
function giveAwayTokens(uint256 value) {
contractA.transferFrom(owner, X, value);
}
}
When I execute "giveAwayTokens" function from owner address (0x123), I get error "Not allowed!". So I am a bit confused right now, because the allowance of owner from owner is max supply. Or maybe the msg.sender is contractB itself? Please enlighten me what I am doing wrong here, thank you
msg.sender
in in the constructor. – Mikko Ohtamaa