Assessment reports>Staking>Threat Model>transferFrom

Function: transferFrom(address _sender, address _recipient, uint256 _amount)

Allows transferring tokens from an account to another.

Inputs

  • _sender

    • Control: Fully controlled by the caller.

    • Constraints: None --- only checked that msg.sender has enough allowance for the particular _sender.

    • Impact: The account that will send the tokens.

  • _recipient

    • Control: Fully controlled by the caller.

    • Constraints: None.

    • Impact: The account that will receive the tokens.

  • _amount

    • Control: Fully controlled by the caller.

    • Constraints: Ensured that msg.sender has enough allowance for the particular _sender.

    • Impact: The amount of tokens to be transferred.

Branches and code coverage (including function calls)

Intended branches

  • Assumes no malicious intent on behalf of the handler.

  • If msg.sender is the handler, do not check allowance.

  • Checks that the _sender has enough balance. Ensured in _transfer.

  • Checks that the _recipient is not the zero address. Ensured in _transfer.

  • Checks that the _amount is greater than zero. Ensured in _transfer.

  • Decreases the balances for the _sender. Ensured in _transfer.

  • Increases the balances for the _recipient. Ensured in _transfer.

  • Decreases the allowance of _sender for msg.sender by _amount. Ensured in _approve.

  • Ensures enough allowance for msg.sender has been granted by _sender.

Negative behavior

  • Should not allow tranferring more tokens than the _sender has, even if the allowance is greater than the balance.

  • Should not allow transferring more tokens than the allowance granted by the _sender.

Zellic © 2024Back to top ↑