LogoLogo
  • 🚀getting started
    • Intro to Data Unions
    • Build a Data Union
      • 1️Installation And Deployment
      • 2️Integration
    • Build a Data Union with Streamr
      • 1️Create A Data Stream
      • 2️Deploy A Data Union With Streamr Core
      • 3️Integrate Data Union & Stream
      • 4️Publish to Streamr Marketplace
    • Glossary of Terms
  • 📚Main Concepts
    • Roles and Responsibilities
      • 🧑‍💻Admin
      • 🤵JoinPart Agents
      • 🙋Member
      • 🧑‍🔧Protocol Beneficiary
    • Join Server
    • Contract Functions
    • Manage Wallets And Earnings
    • Data Union Observation
    • Add Your Own Token
    • Custom Modules
  • 🧐Resources
    • Existing Data Unions
    • Framework Governance
    • Data Unions UX Best Practices
  • ❓Questions?
    • Ask us on Discord
Powered by GitBook
On this page
  • Revenue Distribution
  • Refresh Revenue
  • Check Withdrawable Earnings
  • Withdraw Earnings
  • Weighted Payments
  • Add Members With Weights
  • Set Member Weights
  • Member wallet Management

Was this helpful?

  1. Main Concepts

Manage Wallets And Earnings

PreviousContract FunctionsNextData Union Observation

Last updated 2 years ago

Was this helpful?

The revenue is split between the , the and the (Data Union DAO).

Revenue Distribution

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

Protocol fee ():

Takes 1% of data union revenue, governed by the Data Union DAO, earnings get allocated to the protocolBeneficiary address.

Admin fee ():

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

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

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

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.

Learn more about adding members

Enable your users to connect their own wallet and join via a

📚
join server
admin
members
protocol beneficiary
read more
read more
here
here