C

ch4nn337 - ERC-4337 x Payment Channels

I tried to implement payment channels as ERC-4337 accounts. Unfortunately, it doesn't work the way I envisioned it.


The problem ch4nn337 - ERC-4337 x Payment Channels solves

Note: The following was written before the project failed. See "Challenges I ran into".

Payment channels are a nice way to transact offchain, but require settlement onchain. Furthermore parties can attempt fraud by submitting an outdated channel state to the chain.

When implementing payment channels as a "classical" smart contract, one has to pay for gas to submit fraud proofs or close the channel cooperatively. ERC-4337 not only allows us to pay for gas with funds within the channel (allowing us to submit fraud proofs without another funded account!), but also allows penalizing parties that were proven malicious! For example, if A submits a very old state, and B shows that a more recent state exists, the channel balance of A is used to pay for all gas used in the dispute. This incentivises honesty.

Challenges I ran into

When I first had this idea, I did not fully verify if it will work and decided to just try it out at ETHPrague. During the last efforts I realized that ERC-4337 doesn't work the way I need it to in order for my approach to work. I believe this is fixable (either through two small adjustments to the current implementation of ERC-4337, or through a smarter approach), but this was just not possible to implement until the project deadline. I will outline the details of the attempted solution and why it failed in the readme of the repo (find the link in the left sidebar).

Additionally, this was my first project using Solidity. While the code certainly isn't pretty, I am happy that managed to implement my idea (even though the idea itself was faulty). However, it took some time to get used to it and when I tried to adjust it to (insecurely) work around the issues above, some bug in the implementation prevented testing it.

Oh well. I learned a lot and had a lot of fun, and maybe my detailed findings will help somebody out someday. :)

Tracks Applied (1)

Ethereum Future

Exploring a novel way to use ERC-4337 and supporting the scaling efforts by proposing a way to integrate older technique...Read More

Discussion