2️Integration

Member Joins

Add members manually as the joinPart agent:

circle-exclamation
const PRIVATE_KEY_ADMIN = process.env.PRIVATE_KEY;
// Paste the contract address of your newly created data union
const DU_CONTRACT_ADDRESS = "0x0D483E10612F327FC11965Fc82E90dC19b141641"

const DU = new DataUnionClient({
  auth: {
    privateKey: PRIVATE_KEY,
  },
  chain: 'polygon',
});

const dataUnion = await DU.getDataUnion(DU_CONTRACT_ADDRESS);
const tx = await dataUnion.addMembers(['0xabcd', "0x1234"]);

Or let members join themselves via our default join server:

Your script:
const PRIVATE_KEY_ADMIN = process.env.PRIVATE_KEY;
// Paste the contract address of your newly created data union
const DU_CONTRACT_ADDRESS = "0x0D483E10612F327FC11965Fc82E90dC19b141641"

const DU = new DataUnionClient({
  auth: {
    privateKey: PRIVATE_KEY_ADMIN,
  },
  chain: 'polygon',
});

const dataUnion = await DU.getDataUnion(
    DATA_UNION_CONTRACT_ADDRESS
);

// returns an object with:
// your secret, secret_name, data union contract address and the chain
const sharedSecret = dataUnion.createSecret($custum_secret_name);

Withdraw Earnings

circle-info

When the contract receives revenue in DATA token you need to refresh the contract manually with the contract function refreshRevenue(). The Streamr marketplace arrow-up-rightwill do this automatically for you.

After this transaction your users will be able to see and withdraw their earnings. With every withdraw transaction the revenue will get refreshed automatically.

Last updated

Was this helpful?