Skip to content

Instantly share code, notes, and snippets.

@Yalchin403
Created January 4, 2023 14:54
Show Gist options
  • Save Yalchin403/9f17a9027f8e42640953d56f80a7021e to your computer and use it in GitHub Desktop.
Save Yalchin403/9f17a9027f8e42640953d56f80a7021e to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract MyPayable {
address payable public myAddress;
constructor() payable {
myAddress = payable(msg.sender);
}
function deposit() public payable {}
function getThisContractsBalance() public view returns (uint256){
uint256 amount = address(this).balance;
return amount;
}
function transferEth(address payable _user) public payable {
_user.transfer(msg.value);
}
function sendEth(address payable _user) public payable {
bool didSend = _user.send(msg.value);
require(didSend, "This failed to send");
}
function callEth(address payable _user) public payable {
(bool didSend, ) = _user.call{value: msg.value}("");
require(didSend);
}
receive() external payable {}
fallback() external payable {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment