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

Implement Verida "bank" smart contract #29

Open
tahpot opened this issue May 15, 2022 · 4 comments
Open

Implement Verida "bank" smart contract #29

tahpot opened this issue May 15, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@tahpot
Copy link
Member

tahpot commented May 15, 2022

Background context

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

  • Service registry: Infrastructure providers bond tokens to register database nodes on the network. End users deposit tokens to pay for the infrastructure.
  • Interactions registry (coming soon): Verida accounts deposit tokens to send messages (and other interactions), message recipients receive tokens
  • Trust registry (coming soon): Verida accounts lock tokens when registering themselves on the trust registry (ie: officially registering themselves as a company, or trusting another company)

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:

  • addCredit()
  • removeCredit()
  • lockCredit()
  • unlockCredit()
  • transferCredit()
  • availableCredit()
@tahpot tahpot added enhancement New feature or request question Further information is requested labels May 15, 2022
@tahpot tahpot self-assigned this May 15, 2022
@tahpot
Copy link
Member Author

tahpot commented May 16, 2022

Feedback:

  • Need to ensure we have secure algorithms for users to authenticate their DID.
  • Consider adding a validateTransaction() method that can be used by any Verida smart contract to verify a signature was signed by a DID and can then be trusted. Need to avoid replay attacks.

Next steps:

  • @tahpot expand user stories
  • @tahpot draft initial methods
  • @ITStar10 draft how validateTransaction() method will work
  • @BlockchainCrazy95 draft how locking tokens will work from other smart contracts, such as Service registry
  • ?? write initial smart contract

@tahpot
Copy link
Member Author

tahpot commented May 19, 2022

@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.

@tahpot tahpot assigned pranavburnwal and unassigned tahpot May 19, 2022
@BlockchainCrazy95
Copy link

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
Copy link
Contributor

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants