0

I have seen staking balances using s_balances in contracts.

However, I tried searching around and I could not find the answers.

what is the naming convention around s_ in solidity?

2 Answers 2

1

s_ for "storage".

The s_ is a convention that seems to have been first adopted by the Chainlink developers (example) to indicate that a given variable is a storage variable, and therefore care should be taken in its use.

1

From what I have seen in Patrick Collisions Videos, the s_ is to notify developers that the computation on this data structure is gas-intensive.

For example

    // Account -> Token -> Amount
    mapping(address => mapping(address => uint256))
        public s_accountToTokenDeposits;

On such hashmaps, computations using them could be intensive, so devs would try to minimise changing the data in these datastructure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.