Moving funds from a wallet using smart contract

Suppose I control wallet A. I would like to create a smart contract that withdraws funds from wallet A using its private key.
Suppose further that the smart contract will be created by wallet B.
Wallet B calls the contract function to withdraw these funds from my wallet A.

I need suggestions and clarification to develop this.

you don't need the private key for that. But control of Wallet A.
Wallet A needs to give the contract approval of using the tokens.

interface IERC20 {

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address to, 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 from,
        address to,
        uint256 amount
    ) external returns (bool);

You can use an interface like this.
Then you can intergrate the interface like this:

IERC20 token = IERC20(_address);
function withdraw() public {
 token.transferfrom(WalletA, WalletB, token.balanceOf(WalletA));
1 Like

I would not like to use wallet A because it WILL NOT HAVE the funds to pay the approval gas. And I would not like to do this without having to use wallet A, but using a contract that withdraws tokens/BNB from wallet A. The transaction would be paid by wallet B, because it is he who will send the transaction to the network

I don't think this would work without approval