# named-parameters-mapping

# Description

Solidity v0.8.18 introduced named parameters on the mappings definition.

# Options

This rule does not require any options.

# Example Config

{
  "id": "named-parameters-mapping",
  "severity": "WARNING"
}

# Examples

# Good

To enter "users" mapping the key called "name" is needed to get the "balance"

mapping(string name => uint256 balance) public users;

To enter owner token balance, the main key "owner" enters another mapping which its key is "token" to get its "balance"

mapping(address owner => mapping(address token => uint256 balance)) public tokenBalances;

Main key of mapping is enforced. On nested mappings other naming are not neccesary

mapping(address owner => mapping(address => uint256)) public tokenBalances;

Main key of the parent mapping is enforced. No naming in nested mapping uint256

mapping(address owner => mapping(address token => uint256)) public tokenBalances;

Main key of the parent mapping is enforced. No naming in nested mapping address

mapping(address owner => mapping(address => uint256 balance)) public tokenBalances;

# Bad

No naming at all in regular mapping

mapping(address => uint256)) public tokenBalances;

Missing any variable name in regular mapping uint256

mapping(address token => uint256)) public tokenBalances;

Missing any variable name in regular mapping address

mapping(address => uint256 balance)) public tokenBalances;

No MAIN KEY naming in nested mapping. Other naming are not enforced

mapping(address => mapping(address token => uint256 balance)) public tokenBalances;

# References