Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vault 1 #2

Open
alcueca opened this issue Aug 10, 2021 · 0 comments
Open

Vault 1 #2

alcueca opened this issue Aug 10, 2021 · 0 comments

Comments

@alcueca
Copy link
Owner

alcueca commented Aug 10, 2021

Users can send a given Token to a Vault contract, that records their balance, only that owner can retrieve that token. Think of it as a multi-user safe.

To complete this you will need two contracts, one of them an ERC20 token that will be moved around, and another one the Vault that will store it for the users.

There are a couple of patterns to achieve this, but I suggest that you take the traditional approach:

  1. Vault should import the IERC20 interface, take the Token address in the Vault constructor, and cast it into an IERC20 state variable.
  2. The user approve the Vault to take Token from them in one transaction.
  3. The user calls a function that instructs the Vault to take from them an amount of Token, which now belongs to the Vault, in exchange, the Vault records the user's deposit.
  4. Whenever the user feels like it, it can withdraw its deposit. The Token is returned, and the Vault updates its user records.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant