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 by default 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

Read how you can handle uneven payments to members here

Refresh Revenue

You need to manually refresh the revenue if you don't use the Streamr Marketplace as your revenue source or you don't use a ERC677 token .

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();

Weighted Payments

You can individually assign weights to members if you don't want them to get rewarded equally.

Don't change the weights too often as this will result in defeating the purpose of saving transactions/transaction fees. Try to minimize changing the weight factor as good as you can.

Example:

Address
Weight
Earnings

0x1234

1

2000

0x4321

1

2000

0xabcd

0.5

1000

Calculation: totalWeight = 2.5 receivedRevenue = 5000 token

baseEarnings = receivedRevenue / totalWeight = 5000 / 2.5 = 2000

Earnings for each member:

addr1 = weight * baseEarnings = 1 * 2000 = 2000

addr2 = weight * baseEarnings = 1 * 2000 = 2000

addr3 = weight * baseEarnings = 0.5 * 2000 = 1000

Add Members With Weights

Learn more about adding members here

const tx = await dataUnion.addMembersWithWeights(
      ['0x1234', '0x4321', '0xabcd'],
      [1, 1, 0.5]
);

Set Member Weights

const tx = await dataUnion.setMemberWeights(
      ['0x1234', '0xabcd'],
      [0.2, 0.4]
    );

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.

Last updated