[英]Which address is paying the gas fee? And, can the smart contract pay the gas fee by itself?
pragma solidity ^0.8.1;
contract SendMoney{
uint public publicBalance;
uint public lockedUntil;
function receiveMoney() public payable{
publicBalance += msg.value;
lockedUntil = block.timestamp + 1;
}
function getBalance() public view returns(uint){
return address(this).balance;
}
function withdrawMoney() public{
if(lockedUntil < block.timestamp){
address payable to = payable(msg.sender);
to.transfer(getBalance());
}
}
function withdrawMoneyTo(address payable _to) public{
if(lockedUntil < block.timestamp){
_to.transfer(getBalance());
}
}
}
I have deployed a smart contract with some address lets say.我已经部署了一个带有一些地址的智能合约,可以说。 I sent some ether to the smart contract with the method receive money.我用接收钱的方法向智能合约发送了一些以太币。 Now, when i press on withdrawMoney() function with some another address.现在,当我按下withdrawMoney() function 和另一个地址时。 Who will pay the gas fee?谁来支付燃气费? is it the address that has deployed the smart contract?是部署智能合约的地址吗? or is it the smart contract itself?还是智能合约本身?
The fee for the internal transaction to.transfer(getBalance());
内部交易的费用to.transfer(getBalance());
is included in the total fee paid by the user executing the withdrawMoney()
function.包含在执行withdrawMoney()
function的用户支付的总费用中。
It's currently not possible to split the fee to multiple payers (eg the user paying for the main transaction, and the contract paying for the internal transaction).目前无法将费用分摊给多个付款人(例如,用户为主要交易付款,而合约为内部交易付款)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.