mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-07 03:22:18 +00:00
36 lines
901 B
Solidity
36 lines
901 B
Solidity
|
// SPDX-License-Identifier: LGPL-3.0
|
||
|
|
||
|
pragma solidity ^0.8.0;
|
||
|
|
||
|
contract faucet {
|
||
|
mapping (address => uint256) public sources;
|
||
|
mapping (address => uint256) public destinations;
|
||
|
|
||
|
constructor() {}
|
||
|
|
||
|
event sent(address _destination, uint256 _amount);
|
||
|
event received(address _source, uint256 _amount);
|
||
|
|
||
|
receive() external payable
|
||
|
{
|
||
|
sources[msg.sender] += msg.value;
|
||
|
emit received(msg.sender, msg.value);
|
||
|
}
|
||
|
|
||
|
function send(address payable _destination, uint256 _requested) public payable
|
||
|
{
|
||
|
uint256 amount = 0;
|
||
|
|
||
|
if (address(this).balance > _requested){
|
||
|
amount = _requested;
|
||
|
_destination.transfer(_requested);
|
||
|
}
|
||
|
else{
|
||
|
amount = address(this).balance;
|
||
|
_destination.transfer(amount);
|
||
|
}
|
||
|
|
||
|
destinations[_destination] += amount;
|
||
|
emit sent(_destination, amount);
|
||
|
}
|
||
|
}
|