Unsupported Asset Retrieval Protocol

Overview

The Unsupported Asset Retrieval Protocol is designed to recover ERC20 tokens mistakenly sent to a smart contract without the required deposit function call. This protocol leverages AxiomRepl to enable users to reclaim their assets securely without compromising the integrity of the smart contract.

Background

Smart contracts typically require users to interact through specific functions to deposit assets. Direct transfers not using these functions can result in the permanent loss of assets. AxiomRepl provides a solution to recover such assets.

Example Scenario

Consider a smart contract that accepts ERC20 tokens:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract SomeProtocol {
    using SafeERC20 for IERC20;

    event Deposit(address indexed user, uint256 amount);
    event Withdrawal(address indexed user, uint256 amount);

    mapping(address => uint256) public balances;
    IERC20 public immutable allowedToken;

    constructor(IERC20 _allowedToken) {
        allowedToken = _allowedToken;
    }

    function deposit(uint256 amount) external {
        allowedToken.safeTransferFrom(msg.sender, address(this), amount);
        balances[msg.sender] += amount;
        emit Deposit(msg.sender, amount);
    }

    function withdrawal(uint256 amount) external {
        require(balances[msg.sender] >= amount, "insufficient balance");
        balances[msg.sender] -= amount;
        allowedToken.safeTransfer(msg.sender, amount);
        emit Withdrawal(msg.sender, amount);
    }
}

If a user sends tokens directly to the contract's address, bypassing the deposit() function, those tokens would be stuck. AxiomRepl allows users to prove the occurrence of such a transfer and retrieve their tokens.

Protocol Mechanics

For the retrieval of supported tokens, the process involves staking, a challenge period, and the possibility of zero-knowledge proofs to ensure honesty and security. This complex scenario is beyond the scope of the current demonstration.

Repository Structure

Demonstration Guide

Prerequisites

Ensure you have Node.js and Yarn installed.

Steps

1. Transfer Unsupported ERC20 Token

Simulate an unsupported deposit to the protocol:

2. Submit zk Proof

Prove the unsupported transfer to initiate the refund:

  1. Start the web server:

    yarn dev
  2. Visit localhost:3000 and input the transaction details.

  3. Click "Build and Send Query (on Goerli)".

  4. Proof TX: 0xa4d7df3613d761c36efad9c685d5ca565a25366a1748e48bf3e3ef3e9864dd1b

  • zk Proof Submission

3. AxiomRepl Callback

AxiomRepl will confirm the proof and initiate a callback:

4. Initiate UnsupportedTokenWithdrawal

Users can now withdraw their unsupported tokens:

Conclusion

This protocol provides a secure method for users to reclaim ERC20 tokens sent in error. The demonstration above guides you through the process to safely retrieve your assets.