I read on internet ,after call a non exist founction in contract , that fallback will be actived. address app is a empty contract . address token is busd contract .
address app = 0x85a389C274c62F5108E662F017C04FE22d574483 ;
address token= 0x55d398326f99059fF775485246999027B3197955;
address sender appoved 1 busd to empty contract app already now i call from
app.call(abi.encodeWithSignature("transferFrom(address sender, address recipient, uint256 amount)", sender, recipient,amount));
due to app is empty , so the fallback will be actived , and msg.sender is contract app. and msg.data istransferFrom(address sender, address recipient, uint256 amount) then going to call another
token.call(abi.encodeWithSignature("transferFrom(address sender, address recipient, uint256 amount)", sender, recipient,amount));
at this monment : msg.sender should be address app, msg.data is still "transferFrom(address sender, address recipient, uint256 amount)" and sender already appoved 1 busd to the address app. so it should be working well
here is the full code
pragma solidity ^0.8;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount)
external
returns (bool);
function allowance(address owner, address spender)
external
view
returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract callnmblq {
address app = 0x85a389C274c62F5108E662F017C04FE22d574437 ;
address token= 0x55d398326f99059fF775485246999027B3197955;
function transferFrom( address sender, address recipient, uint256 amount) external {
bool success;
(success, ) =app.call(abi.encodeWithSignature("transferFrom(address sender, address recipient, uint256 amount)", sender, recipient,amount));
require(success,"fall to transferFrom");
(success, ) =token.call(abi.encodeWithSignature("transferFrom(address sender, address recipient, uint256 amount)", sender, recipient,amount));
require(success,"fall to transferFrom");
}
}
help to check the logic.if i understand well at the seconder call msg.sender and msg.data. help to understand after fallback active , how to continue contract. help how to make this transferFrom working . by the way the feedback is gas limited
transact to callnmblq.transferFrom errored: Internal JSON-RPC error.
{
"code": 3,
"message": "execution reverted: fall to transferFrom",
"data": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001466616c6c20746f207472616e7366657246726f6d000000000000000000000000"
}