'Can gas fees be paid from another account when transferring tokens using Web3?

bsc = 'https://bsc-dataseed.binance.org/'
        web3 = Web3(Web3.HTTPProvider(bsc))
        # print(web3.isConnected())
        account_1 = '0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
        private_key1 = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
        account_2 = '0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
        balance = web3.eth.get_balance(account_1)
        human_readable = web3.fromWei(balance, 'ether')
        print("Balance : " + str(human_readable))
        if balance > 0.01:
            nonce = web3.eth.getTransactionCount(account_1)
            tx = {
                'nonce': nonce,
                'to': account_2,
                'value': web3.toWei(balance, 'ether'),
                'gas': 21000,
                'gasPrice': web3.toWei(5, 'gwei')
            }
            signed_tx = web3.eth.account.sign_transaction(tx, private_key1)
            tx_hash = web3.eth.sendRawTransaction(signed_tx.rawTransaction)
            print(web3.toHex(tx_hash))

I am transferring with this code. However, while doing these transactions, I want to pay the transfer fee with another account. Is it possible. Contract, approve ...



Solution 1:[1]

I am transferring with this code. However, while doing these transactions, I want to pay the transfer fee with another account. Is it possible. Contract, approve

You can read about meta transactions and gasless transactions here.

They are not implemented on BNB Chain, so it is not possible.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mikko Ohtamaa