Loading...
pragma solidity ^0.8.5;
contract send_ether {
function send() public payable{
}
function getbalance() public view returns(uint256) {
return address(this).balance;
}
}
In above smart contract two functions are present one is send() and onother is getbalance().
send() function is used for deposting ethers in smart contract & getbalance() function is used for getting the balance of smart contract.
To deopsit ethers in smart contract or for sending ethers from one address to another the function should be payable.
Making the payable means that we are allowing that functions to send ethers or any type of transactions in which ethers are going to send .
Finally getbalance() function returns the ethers or balance of smart contract in the form of wei (smallest unit of ether) , the .balance attribute is used for getting the balance of smart contract .