Skip to content

[backends/eth] Use approve instead of increaseAllowance for ERC20 deposit #4

Open
@manoranjith

Description

@manoranjith

Location

[backend/ethereum/channel]

Problem

Currently, for funding a channel with ERC20 tokens, we use increaseAllowance to set the amount that the perun contracts can transfer from the user's account.

However, the increaseAllowance functions is not a part of the ERC20 standard interface, but an extension provided by open zepplin reference implementation of ERC20 token standard. It is provided as an alternative to approve, in order to avoid some of the issues associated with approve function. However, the ERC20 token standard does not include this extension for maintaining backward compatibility and suggests careful usage of the approve method as the solution to deal with the issues.

Links: attack description, , discussion related to it and suggested mitigation technique.

Proposal

Replace the usage of increaseAllowance with approve method.

However, the implementation would be tricky and not straightforward. Especially when we consider the scenario where, a user wants to fund multiple channels with the same ERC20 token (described below).

Say a user wants to fund ch1 with 10 PRN tokens and ch2 with 20 PRN tokens.
The challenge here would be

  1. First, we set the allowance to 10 PRN.
  2. Then we want to increase it by 20 PRN. Because there is not a straightforward way to atomically increase the allowance using the interfaces defined in ERC20 standard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions