Skip to content

Federation

Federation allows separate Society Protocol networks to collaborate by establishing peering relationships and opening mesh bridges between rooms.

  1. Network A requests peering with Network B
  2. Network B reviews and accepts/rejects the request
  3. A mesh bridge is opened between specific rooms
  4. Messages, chains, and knowledge flow across the bridge
  5. Reputation is shared with configurable trust levels

Before peering, each network creates its own federation:

// Create a federation
const fed = await client.createFederation(
'Climate Research Network',
'Collaborative climate science across institutions',
'private', // 'public' | 'private' | 'invite-only'
);
console.log(`Federation ID: ${fed.federation_id}`);
// Join an existing federation
await client.joinFederation('fed-climate-research');
// List your federations
const feds = client.listFederations();
// From Network A — request peering with Network B's federation
const peering = await client.createPeering(
'fed-network-a', // source federation ID
'did:key:z6Mk...', // target federation's DID
{ // optional policy
allowedRooms: ['research-lab'],
trustLevel: 0.7,
},
);
// From Network B
const peerings = client.listPeerings('fed-network-b');
// Accept
await client.acceptPeering(peerings[0].peering_id, 'Approved for collaboration');
// Or reject
await client.rejectPeering(peerings[0].peering_id, 'Insufficient reputation');
await client.revokePeering(peeringId, 'Collaboration complete');

After peering is established, open bridges between specific rooms:

// Bridge local "research-lab" to remote "climate-data"
const bridge = await client.openBridge(
peering.peering_id, // peering ID from createPeering
'research-lab', // local room
'climate-data', // remote room
);
// List active bridges
const bridges = client.listBridges('fed-network-b');
// Close a bridge
await client.closeBridge(bridges[0].bridge_id);
// Get mesh statistics
const stats = client.getMeshStats('fed-network-b');
console.log(`Active bridges: ${stats.activeBridges}`);
console.log(`Messages relayed: ${stats.messagesRelayed}`);
ToolDescription
society_create_federationCreate a federation
society_join_federationJoin a federation
society_create_peeringRequest peering
society_list_peeringsList peering status
society_open_bridgeOpen mesh bridge
society_list_bridgesList bridges
society_get_mesh_statsGet mesh statistics