Function: depositERC20(address _token, bytes _to, uint256 _amount, uint256 _gasLimit, uint256 _keyId)
This function deposits some token to a recipient's account on Cloak. The caller needs to attach ETH to pay for the relayer fee.
Inputs
_tokenControl: Fully controlled by the caller.
Constraints: Must be an ERC-20 token with metadata.
Impact: The deposited token address on Scroll.
_toControl: Fully controlled by the caller.
Constraints: N/A.
Impact: The encrypted address of the recipient on Cloak.
_amountControl: Fully controlled by the caller.
Constraints: Must be greater than zero.
Impact: The amount of tokens to transfer.
_gasLimitControl: Fully controlled by the caller.
Constraints: Must be lower than the
maxGasLimitspecified in the contract SystemConfig.Impact: The gas limit required to complete the deposit on Cloak.
_keyIdControl: Fully controlled by the caller.
Constraints: Must be the latest key ID stored in the contract ScrollChainValidium.
Impact: The encryption key ID of the key used to encrypt the address of the recipient.
Branches and code coverage
Intended branches
Emits a
QueueTransactionevent when the deposit is successful.The
_tokenbalance of the caller decreases by_amount.Adjusts, for fee-on-transfer tokens, the amount based on the actual received tokens.
Negative behavior
Reverts if trying to reenter the function.
Reverts if the
_keyIdis not the latest.Reverts if the amount of
_tokenreceived by the contract is zero.Reverts if there is insufficient value to pay for the relayer fee.
Reverts if the
_tokendoes not have metadata.Reverts if the
symbolandnamefunctions of the_tokenreturn data of typebytes32.
Function call analysis
this._deposit(_token, this._msgSender(), _to, _amount, new bytes[0], _gasLimit, _keyId) -> this._transferERC20In(this._msgSender(), _token, _amount) -> SafeERC20Upgradeable.safeTransferFrom(IERC20Upgradeable(_token), _from, address(this), _amount)What is controllable?
_tokenand_amount.If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? There are no changes to the state variables before this transfer, so reentry does not matter.
this._deposit(_token, this._msgSender(), _to, _amount, new bytes[0], _gasLimit, _keyId) -> IL1ScrollMessenger(this.messenger).sendMessage{value: msg.value}(this.counterpart, 0, _message, _gasLimit, _from)What is controllable?
_messageand_gasLimit.If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? N/A.