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
  • Automate Member Joins With Our Default Join Server
  • Build Your Own Join Server

Was this helpful?

  1. Main Concepts

Join Server

PreviousProtocol BeneficiaryNextContract Functions

Last updated 2 years ago

Was this helpful?

Automate member joins with a join server.

Your data union smart contract prevents addresses adding themselves as members to the data union. Only a can add new members to the data union.

A join server acts as a request instance between the new member and the smart contract.

A member sends a request to the server and the server sends a transaction signed by a to the contract to add the member.

Data Union DAO provides a that handles the automated joins via a shared secret.

We recommend implementing your own business logic and set of rules under what conditions members are allowed to join. You can use our as a starting point (the default join server uses the join server as a base too).

Automate Member Joins With Our Default Join Server

Shared secrets allow new members to join the Data Union without a manual transaction from a joinPart agent.

The functions createSecret, listSecrets and deleteSecret can only get called by the admin. Thus the data union client private key must be from the admin.

Once you got the shared secret, save it in an environment variable.

Generate a shared secret with the SDK:

import { DataUnionClient } from '@dataunions/client';

const DU = new DataUnionClient({
  auth: {
    privateKey: PRIVATE_KEY_ADMIN,
  },
  // only if you don't want to use the default joinServer
  joinServerUrl: "YOUR_CUSTOM_SERVER_URL"
  chain: 'polygon',
});

const dataUnion = await DU.getDataUnion(
    DATA_UNION_CONTRACT_ADDRESS
);

// -------- ADMIN ONLY FUNCTIONS --------

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

// list all your secrets
// typically there is one secret per data union
const sharedSecrets = dataUnion.listSecrets()

// -------- MEMBER FUNCTION --------

// your members can now join like this
// store the shared secret in an environment variable
const memberDetails = await dataUnion.join({
    secret:process.env.SHARED_SECRET
});

Build Your Own Join Server

If you build your own custom server you'll need to make an adjustment to your client setup:

const DU = new DataUnionClient({
  auth: WALLET_PROVIDER,
  joinServerUrl: "yourURL", //add your custom joinServerUrl
  chain: 'polygon',
});

Here you can implement logic like under what circumstances wallet addresses can join. E.g. only with proof of humanity verification or only addresses with an ens or only addresses that have proven to be valuable data provider. It's your decision to make.

Again the only requirement for a member join the default join server has is providing the shared secret. So anyone with the shared secret can essentially join the data union.

You might find the default join servers join requirement too basic (shared secret). We highly recommend implement your own logic. You can use the as a starting point. The default join server uses this repository as the base too.

๐Ÿ“š
join server repository
joinPart agent
joinPart agent
default join server
join server
Logodata-unions/packages/default-join-server at main ยท dataunions/data-unionsGitHub
default join server
Logodata-unions/packages/join-server at main ยท dataunions/data-unionsGitHub
base for custom join server
Logodata-unions/packages/join-server at main ยท dataunions/data-unionsGitHub