Omniscia DAFI Protocol Audit

basictoken Code Style Findings

basictoken Code Style Findings

BAS-01C: Inexistent Visibility Specifiers

TypeSeverityLocation
Code StyleInformationalbasictoken.sol:L6, L8

Description:

The linked variables have no visibility specifier explicitly set.

Example:

contracts/basictoken.sol
6mapping(address => uint256) balances;
7
8uint256 _totalSupply;

Recommendation:

We advise one to be set so to avoid potential compilation discrepancies in the future as the current behaviour is for the compiler to assign one automatically which may deviate between pragma versions.

Alleviation:

Both linked variables were set as internal.

BAS-02C: Redundant require Check

TypeSeverityLocation
Gas OptimizationInformationalbasictoken.sol:L23

Description:

The transfer function redundantly evaluates whether the msg.sender has sufficient balance to transfer as that is already indirectly evaluated by the safe subtraction performed on line 25.

Example:

contracts/basictoken.sol
16/**
17 * @dev transfer token for a specified address
18 * @param _to The address to transfer to.
19 * @param _value The amount to be transferred.
20 */
21function transfer(address _to, uint256 _value) public override returns (bool) {
22 require(_to != address(0),"Cannot call transfer with to as ZERO ADDRESS");
23 require(_value <= balances[msg.sender],"cannot transfer amount more than your balance");
24
25 balances[msg.sender] = balances[msg.sender] - _value;
26 balances[_to] = balances[_to] + _value;
27 emit Transfer(msg.sender, _to, _value);
28 return true;
29}

Recommendation:

We advise the require check to be omitted in favor of gas cost or the subtraction to be performed within an unchecked code block.

Alleviation:

The balance subtraction is now optimally executed within an unchecked block.