Warm tip: This article is reproduced from serverfault.com, please click

How to send Ether Using Web3 and Gas Charges are Paid from Another Address?

发布于 2020-12-13 22:54:16

I know using this for send Ether (web3):

web3.eth.sendTransaction({
    from: 'Address A',
    to: 'Address B',
    value: '1000000000000000'
})
.then(function(receipt){
    ...
});

I'm trying to send ether from address A to address B, then the gas fee is paid by address C for the transaction. Does anyone know about that?

Questioner
Zoro Raka
Viewed
0
Ming 2020-12-14 15:17:57

Unlike Bitcoin's raw transaction you create payload with listunspent, you can't do this for ether in Ethereum.

However you can do this for tokens. Ex: ERC20 Token, you can have address A to approve address C to spend his/her ERC20 on their behalf. Once the approve transaction has completed, address C can bear the gas for transferring ERC20 token from address A to address B.