verida / blockchain-contracts

Smart contracts, part of the protocol powering the Verida Network
https://www.verida.network
Apache License 2.0
7 stars 2 forks source link

Implement Verida "bank" smart contract #29

Open tahpot opened 2 years ago

tahpot commented 2 years ago

Background context

We currently have multiple smart contracts in our network architecture require users to "bond" or "lock" tokens:

The service registry currently implements addCredit() and removeCredit() methods that support depositing VDA tokens that can then be used transfer VDA tokens between users based on the service infrastructure each account uses.

In the future, the interactions registry and the trust registry will require similar functionality.

We require a separate vda bank smart contract that provides a common way to "lock" tokens in the Verida network, that can then be moved around by any of our Verida smart contracts. It acts like a Verida bank where each smart contract can lock, unlock or transfer tokens in this common deposit contract.

This will also allow for a simpler user experience because a user can lookup at the vda bank smart contract and see how many of their tokens are locked by different verida smart contracts, how much credit they have and where their tokens are being spent across the Verida network.

This also provides the best way to allow VDA community token holders to support the network (via gasless transaction payments) while also receiving a return for their staking.

User stories

TBA

Methods

TBA

Phase 1

For phase 1, we only require the necessary functionality to support the service registry.

This is likely:

tahpot commented 2 years ago

Feedback:

Next steps:

tahpot commented 2 years ago

@pranavburnwal suggests using OpenZeppelin contracts, that leverage vesting and think if of this as a "virtual" (ERC1155) contract that is for DID's not blockchain wallets.

BlockchainCrazy95 commented 2 years ago

Accounts will charge the credits using addCredit() or removeCredit() function as in the Service Registry contract. They will record all the credit amount in the VDA bank contract. If service registry contract requires tokens, it will only lock up tokens in VDA bank contract and it will free up when it needs. Tokens will be stored in the VDA bank contract and amount will be managed in this contract too.

pranavburnwal commented 2 years ago

@pranavburnwal suggests using OpenZeppelin contracts, that leverage vesting and think if of this as a "virtual" (ERC1155) contract that is for DID's not blockchain wallets.

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/escrow/Escrow.sol https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/escrow/RefundEscrow.sol

@tahpot These are the contracts I was mentioning about. Lets see how we can use to build this.

cc @ITStar10