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

blockchain-如何使用Web3发送以太币,煤气费是从另一个地址支付的?

(blockchain - How to send Ether Using Web3 and Gas Charges are Paid from Another Address?)

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

我知道用这个来发送Ether(web3):

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

我正在尝试将以太币从地址A发送到地址B,然后由地址C支付交易的汽油费。有人知道吗?

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

与比特币的原始交易不同,你使用创建的有效负载listunspent,你无法在以太坊中为以太币进行此操作。

但是,你可以为令牌执行此操作。例如:ERC20令牌,你可以使用地址A到approve地址C来代表他们使用他/她的ERC20。一旦approve交易完成,地址C可承受的气体从地址令牌传递ERC20到地址B.