Let's say I have a simple Solidity wallet contract as shown below. When I want to withdraw from the contract using send
the transaction fees (gas cost) are reduced from the amount the receiving party gets. How can I send ether from the smart contract so that gas cost is imposed on the contract itself, not on the receiver?
Also, I want to know the fee imposed on the wallet before calling the contract. Is it possible to determine the fee that is imposed for send()
over JSON-RPC interface?
/**
* Simple hosted wallet contract.
*/
contract Wallet {
event Deposit(address from, uint value);
event Withdraw(address to, uint value);
address owner;
function Wallet() {
owner = msg.sender;
}
/**
* Simple withdrawal operation.
*/
function withdraw(address _to, uint _value) {
if(msg.sender != owner) {
throw;
}
Withdraw(_to, _value);
_to.send(_value);
}
/**
* Somebody sends ETH to this contract address
*/
function() {
// just being sent some cash?
if (msg.value > 0) {
Deposit(msg.sender, msg.value);
}
}
}