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

Message interactions contract #17

Open
tahpot opened this issue Mar 28, 2022 · 0 comments
Open

Message interactions contract #17

tahpot opened this issue Mar 28, 2022 · 0 comments
Assignees

Comments

@tahpot
Copy link
Member

tahpot commented Mar 28, 2022

This project requires developing a smart contract that distributes tokens to multiple addresses as part of an “interaction” that occurs off-chain.

In our case, there is a “sender” who is sending data to a “receiver”. In order for this to work, there are two decentralized applications; the “sender dApp” and the “receiver dApp”.

The sender “pays” for an interaction by using credits stored in the smart contract. The “receiver”, “receiver dApp” and “sender dApp” all receive a portion of the fees paid by the “sender”.

Methods

  • addFunds(did: string, numTokens: integer) — Add credit for a DID. A user adds VDA tokens to this smart contract for a given DID.
  • removeFunds(did: string, numTokens: integer, signature: string) — Remove credit from a DID. A user reduces their credits and receives VDA tokens from this smart contract to their address. Verify signature is generated by the DID signing a message (${did} authorizes removing credit of ${numCredits} at ${timestamp}) where ${timestamp} is within 30(?) seconds of the current time.
  • submitInteraction(interactionId: string, senderDid: string, receiverDid: string, sendingAppDid: string, receivingAppDid: string) — Submit an interaction which distributes credits (see split below).
  • hasInteraction(interactionId: string) — Read only method that verifies if a particular interaction has been registered
  • setExchangeRate(rate: decimal) — (owner only) Set the exchange rate of how many VDA tokens are required to pay for an interaction.

Requirements

Interaction distributions

An interaction can be submitted to the smart contract by a “sender”. The sender must also specify the receiving address, sender dApp, receiver dApp.

An interaction will decrease the number of credits owned by the “sender”, by one.

An interaction will credit ETH stored in the smart contract to other addresses involved in the interaction as follows:

  • Receiver (50%)
  • Sending dApp (20%)
  • Receiving dApp (20%)
  • Network (10%)

Note: For now the Network tokens will accrue in the smart contract. In the future, these will be distributed to a separate network staking contract and distributed to token holders who stake tokens.

Exchange rate

The exchange rate is designed to maintain a stable price of credits in USD. This is achieved by adjusting the exchange rate of how many VDA tokens purchase how many message interactions.

Deliverables

  • All code submitted to https://github.com/verida/blockchain-contracts/vda-message-interactions
  • A smart contract that meets the project requirements and provides (at least) the methods above.
  • Tests that verify the smart contract is working as expected
  • Deployment to Polygon Testnet
  • Basic documentation on how to setup, run the code and tests
@tahpot tahpot changed the title [poc] Message interactions contract Message interactions contract Apr 21, 2022
@ysam21 ysam21 assigned tahpot and unassigned pranavburnwal Sep 13, 2022
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

2 participants