Manage Wallets And Earnings

The revenue is split between the admin, the members and the protocol beneficiary (Data Union DAO).

Revenue Distribution

The revenue distribution is defined by two variables in the smart contract:

Protocol fee (read more):

Takes 1% of data union revenue, governed by the Data Union DAO, earnings get allocated to the protocolBeneficiary address.
Admin fee (read more):
Takes x% of data union revenue, can be changed at any time by the admin (previous earnings are not affected when changed), earnings get allocated to the admin/owner address
Individual member earnings:
Is calculated as follows:
totalMemberEarnings = revenue - (revenue * (adminFee + protocolFee)
individualMemberEarnings = totalMemberEarnings / allActiveMembers

Refresh Revenue

You need to manually refresh the revenue if you don't use the Streamr Marketplace as your revenue source.
Whenever your data union contract receives token aka revenue you need to refresh it after the transaction before users can withdraw or see their earnings.
const tx = await dataUnion.refreshRevenue();
The revenue then gets refreshed after every withdraw call.

Check Withdrawable Earnings

Members can check their earnings (minus earlier withdrawals) like this:
const amount = await dataUnion.getWithdrawableEarnings();

Withdraw Earnings

const tx = await dataUnion.withdrawAll();

Member wallet Management

Members are identified by an Ethereum address. The address is used to authenticate the member by signing requests with their associated private key.
There are two ways to enable users to interact with the data union infrastructure:
  • Manage the member wallets yourself by generating and storing the private key
  • Enable your users to connect their own wallet and join via a join server

Manage member wallets yourself

If your users don't have crypto wallets you can generate a wallet address yourself and store it securely on a server:
import { DataUnionClient } from '@dataunions/client';
const wallet = DataUnionClient.generateEthereumAccount();
The data-producing application can generate the keys when it is launched for the first time, and store the information locally or the user may connect their existing wallet. The private key should always stay on the device and it should never be sent over the internet.
Storing the private key in encrypted form is recommended. One way to approach this is to encrypt it using a user-defined password. If the key is stored encrypted, the key needs to be decrypted when the application starts. The decrypted version should be kept in memory, as it is continuously needed for signing data.