Skip to content

Message interactions contract #17

Description

@tahpot

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions