erigon-pulse/cmd/devnet/contracts/faucet.sol
Mark Holt 751f62615d
Devnet sync events (#7911)
This request implements an end to end Polygon state sync in the devnet.

It does this by deploying smart contracts ont the L2 & L2 chain which
follow the polygon fx portal model with security checks removed to
simplify the code. The sync events generated are routed through a local
mock heimdal - to avoid the consensus process for testing purposes.

The commit also includes support code to help the delivery of additional
contract based scenratios.
2023-07-20 23:10:18 +01:00

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);
}
}