是否有办法让付款人成为另一个帐户web3py



是否有可能在ETH链上有一个由account_1签署的交易,但由account_2发送并支付费用?

我知道这在solana中是可能的,但我在以太坊中找不到答案。

我想做的是发送一些ERC20令牌,从account_1到account_2,而不必发送eth到account_2。

# Fetch the token balance    
token_balance = contract.functions.balanceOf(acc2).call()
# Contract Address
contract = web3.eth.contract(address=USDT_CONTRACT_ADDRESS, abi=abi, )
# SEtting the acc_1 as the default account for the Web3 Instance
contract.web3.eth.default_account = acc1
web3.eth.default_account = acc1_eth.address
gasPrice = web3.eth.gasPrice
tx = contract.functions.approve(acc1, token_balance).buildTransaction({
'from': acc2,
'nonce': web3.eth.getTransactionCount(acc2),
"gasPrice": gasPrice, 
"chainId": 1
})
# Prior to this line, i get:
## {'code': -32000, 'message': 'gas required exceeds allowance (0)'}
# i cant set the gasPrice to 0 becaue then i will get `ContractLogicError`
signed_tx = acc2_eth.sign_transaction(tx)
a = web3.eth.sendRawTransaction(signed_tx.rawTransaction)
tx_receipt = web3.eth.wait_for_transaction_receipt(a)
print(f"TXID => { tx_receipt.transactionHash.hex() }")

p。d。我确实拥有两个账户的私钥,但其中一个是一次性的,这就是为什么我不想给它任何ETH。

是否有可能在ETH链上有一个由account_1签署的交易,但由account_2发送并支付费用?

不,它不是。

最新更新