Skip to content

Instantly share code, notes, and snippets.

@ArslanKathia
Created January 31, 2023 17:32
Show Gist options
  • Save ArslanKathia/b34f75b3fb1d7d7cdf6cacc785bbd265 to your computer and use it in GitHub Desktop.
Save ArslanKathia/b34f75b3fb1d7d7cdf6cacc785bbd265 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 Payable{
// address make it payable
address payable public owner = payable(msg.sender);
//at the time of deployment we can sent the wei in the contract
constructor() payable{
}
//function make it payable so we get the wei in the contract 1 eth = 10^8 wei
//One ether = 1,000,000,000,000,000,000 wei (1018)
//we can make a function a payable because we have to get the more ether in the contract
function getEth() public payable {
}
//check balance
function checkBalance() public view returns(uint){
return address(this).balance;
}
function checkOnwerBalance() public view returns(uint){
return owner.balance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment