What is “Payable” keyword in solidity?

Ayleen Crypto
2 min readMay 14, 2021
smart contract codes

Solidity is a programming language made specifically for EVM (Ethereum Virtual Machine) and it’s really great. Not to mention that most of the smart contract blockchain nowadays also adopt Solidity as one of their preferred language to develop smart contract simply because the community of Solidity itself is the most active compared to other smart contract programming language. But, have you ever try to skim through smart contract code and doesn’t understand what the heck is “Payable” keyword in function and in a variable?

solidity logo

“Payable” Keyword is basically just a keyword that allows us to make transfer from external address to smart contract address or from smart contract address to external address. It means without that keyword we won’t able to have access to address method .transfer that allows us to send ETH to external address or we won’t able to receive ETH from external address to the smart contract address without the keyword “payable” to our function.

For example, to receive ETH transfer from external address to our smart contract address using function we need to give keyword “payable” after the argument in a function

function receiveMoney() public payable {

//Do something ehre

}

Using that keyword, it allows for external address to send ETH to our smart contract address, also

function withdrawMoney(address payable _to) {

//Do something here

}

this allows us to be able to send ETH from our smart contract address to external address since keyword “payable” gives method .transfer to the address passed to the function as an argument.

So basically, a “payable” keyword is essential if your smart contract code involves transfer to external address whether going in or out. Without it, smart contract code would be significantly useless because, that’s the whole point of smart contract right?

--

--

Ayleen Crypto

CryptoCurrency Enthusiast || Smart Contract Developer