I heard that it is possible to make multiple transactions like, "send eth to account b" and then instantly "send tokens from account b to a" in one batch.
I don't know how I would do that though, does anyone know how to achieve this?
Thanks!
you can use smart contract for that.
interface IERC20{
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}
contract Contract {
// this requires B to approve amount to the Contract from token address and A calls this function
function oneTransaction(address token, address B, address A, uint256 amount) external payable {
(bool sent, bytes memory data) = B.call{value: msg.value}("");
require(sent, "Failed to send Ether");
IERC20(token).transferFrom(B, A, amount);
}
}
If there is a function in b that on receiving funds immediately sends them to a, it is possible. That would be one transaction.