Search…
⌃K

Join Server

Automate member joins with a join server.
Your data union smart contract prevents addresses adding themselves as members to the data union. Only a joinPart agent 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 joinPart agent to the contract to add the member.
Data Union DAO provides a default join server 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 join server 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',
});
You might find the default join servers join requirement too basic (shared secret). We highly recommend implement your own logic. You can use the join server repository as a starting point. The default join server uses this repository as the base too.
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.