Questions tagged [conventions]

A generic tag covering any accepted method of doing things, which could include naming, spacing, coding, commenting, etc.

Filter by
Sorted by
Tagged with
1 vote
1 answer

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 ...
progress Ibrahim's user avatar
2 votes
3 answers

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?
samuelnihoul's user avatar
0 votes
1 answer

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 ...
Taras Filatov's user avatar
0 votes
2 answers

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 ...
EtherPaul's user avatar
  • 257
13 votes
2 answers

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 ...
goodvibration's user avatar
1 vote
0 answers

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 ...
otembajelle's user avatar
4 votes
0 answers

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 ...
eth's user avatar
  • 85.1k
24 votes
3 answers

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 ...
Joël's user avatar
  • 1,710