Skip to content

Instantly share code, notes, and snippets.

@ArslanKathia
Created February 1, 2023 19:38
Show Gist options
  • Save ArslanKathia/d4ab1d1fedf8640b8ba7e99da47c7877 to your computer and use it in GitHub Desktop.
Save ArslanKathia/d4ab1d1fedf8640b8ba7e99da47c7877 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;
contract SentEther{
//address payable public getter = payable(0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2);
//add the ether in the smart contract using transact
receive() external payable{}
function checkBalance() public view returns(uint){
return address(this).balance;
}
// //sent gas fee is 2300
// function SEND(address payable getter) public{
// bool sent = getter.send(1000000000000000000);
// require(sent,"Transaction is failed");
// }
// //transfer gas fee is 2300
// function TRANSFER(address payable getter) public{
// getter.transfer(1000000000000000000);
// }
// //call gas fee is user defined limit
// function Call(address payable getter) public{
// //(bool sent,bytes memory data) = getter.call{value:1000000000000000000}("");
// (bool sent,) = getter.call{value:1000000000000000000}("");
// require(sent,"Transaction is failed");
// }
//sent gas fee is 2300
//here ether is direct sent to address
function SEND(address payable getter) public payable{
bool sent = getter.send(msg.value);
require(sent,"Transaction is failed");
}
//transfer gas fee is 2300
//here ether is direct sent to address
function TRANSFER(address payable getter) public payable{
getter.transfer(msg.value);
}
//call gas fee is user defined limit
//here ether is direct sent to address
function Call(address payable getter) public payable{
//(bool sent,bytes memory data) = getter.call{value:1000000000000000000}("");
(bool sent,) = getter.call{value:msg.value}("");
require(sent,"Transaction is failed");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment