Black RoseⓂ️🎭⚡💎🗿
@blackrosemmav
2305 Following
1660 Followers
0 reply
0 recast
0 reaction
0 reply
0 recast
0 reaction
4 replies
0 recast
0 reaction
3 replies
0 recast
0 reaction
1 reply
0 recast
0 reaction
1 reply
0 recast
0 reaction
2 replies
0 recast
1 reaction
3 replies
0 recast
0 reaction
2 replies
0 recast
0 reaction
1 reply
0 recast
0 reaction
0 reply
0 recast
0 reaction
Learn about Solidity 💡⚡️
How functions work in Solidity:
1. **Definition**: Functions are defined using the `function` keyword, followed by the function name, parameters, and a return type if applicable.
💎
2. **Visibility**: Functions can have visibility modifiers like `public`, `private`, `internal`, or `external`, determining who can call the function. The example above uses `public`, meaning it can be called from anywhere.
💎
3. **Implementation**: The block of code within curly braces `{}` contains the function's logic, and you can return values using the `return` statement if a return type is specified. For instance:
```solidity
return a + b;
```
💎
Here's a complete example of a simple add function in a contract:
```solidity
pragma solidity ^0.8.0;
contract SimpleCalculator {
function add(uint a, uint b) public pure returns (uint) {
return a + b;
}
}
```
❤️🔥
This contract allows you to add two numbers on the blockchain! 1 reply
0 recast
0 reaction
4 replies
0 recast
0 reaction
0 reply
0 recast
0 reaction
0 reply
0 recast
0 reaction
1 reply
0 recast
2 reactions
1 reply
0 recast
0 reaction
2 replies
0 recast
0 reaction
0 reply
0 recast
0 reaction
0 reply
0 recast
0 reaction