Questions tagged [conventions]
A generic tag covering any accepted method of doing things, which could include naming, spacing, coding, commenting, etc.
8
questions
1
vote
1
answer
104
views
Where to place special functions receive() & fallback()?
receive() external payable {
fund();
}
fallback() external payable {
fund();
I want to find out where exactly should these special functions be wrriten; should they come before the contract ...
2
votes
3
answers
144
views
What does "safe" mean in smart contract engineering?
Many times there are duplicate codes. For example, one function is safeTransfer and the other is Transfer. Another example is token vs safeToken. What is this naming convention?
0
votes
1
answer
346
views
Solidity functions naming order [closed]
The only documented convention about naming the functions in smart contracts seems to be that it should be camelCase.
The order of subjects and actions seems to be arbitrary unless I'm missing ...
0
votes
2
answers
836
views
Convert a string in scientific notation to a number
my smart contract uses an Oracle to retrieve the price. The price is returned as a string in scientific notation, for example, "3e-8". How I can convert this to number (uint)? The token has ...
13
votes
2
answers
2k
views
Should I give names to return values, when a function returns several of them?
I am currently working with solc v0.4.25, where it is not possible to return structures, so the only way to return multiple values is in a tuple.
I've been advised to give names to each one of the ...
1
vote
0
answers
453
views
Naming conventions for ERC-20 instancies [duplicate]
Given a contract that implements ERC-20. Is there a naming convention for new instancies such as its symbol? We are used to 3 chars but that range will run out at some time in future.
I am asking ...
4
votes
0
answers
737
views
Why are underscores used in front of parameters, instead of contract member variables? [duplicate]
In Solidity, for example, why:
function Greeter(string _greeting) public
{
greeting = _greeting;
}
instead of:
function Greeter(string greeting) public
{
_greeting = greeting;
}
The latter ...
24
votes
3
answers
13k
views
What is the purpose of underscores in front of parameters?
I see contracts that use underscores in front of parameter names, like so:
function Greeter(string _greeting) public
{
greeting = _greeting;
}
What's the purpose of these underscores? Do they ...