Developers
Live Playground
3.1. Query mixnet contract for a list of mix nodes

Query for Mixnodes

Query the Nym Mixnet smart contract for a live list of registered Mix Nodes. This demo uses @nymproject/contract-clients to read on-chain data directly from your browser, no backend required.

Try it: Click the button to fetch the current page of Mix Nodes from the Mixnet Contract. Each entry shows the node's identity key, owner address, and bonding details.

How this works

The component creates a MixnetContractClient connected to the Nyx blockchain and calls getMixNodesPaged() to retrieve a paginated list of bonded Mix Nodes. This is a read-only query; no wallet or signing is needed.

MixnodeContractQueryExample.ts
import { useEffect, useState } from "react";
import { contracts } from "@nymproject/contract-clients";
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
import { settings } from "./client";
import Box from "@mui/material/Box";
import CircularProgress from "@mui/material/CircularProgress";
 
const getClient = async () => {
  const cosmWasmClient = await SigningCosmWasmClient.connect(settings.url);
 
  const client = new contracts.Mixnet.MixnetQueryClient(
    cosmWasmClient,
    settings.mixnetContractAddress
  );
  return client;
};
 
export const Mixnodes = () => {
  const [mixnodes, setMixnodes] = useState<any>();
 
  const getMixnodes = async () => {
    const client = await getClient();
    const { nodes } = await client.getMixNodesDetailed({});
    setMixnodes(nodes);
  };
 
  useEffect(() => {
    getMixnodes();
  }, []);
 
  if (!mixnodes) {
    return (
      <Box sx={{ display: "flex" }}>
        <CircularProgress />
      </Box>
    );
  }
 
  return (
    <div style={{ marginTop: "1rem" }}>
      {mixnodes?.length &&
        mixnodes.map((mixnode: any) => (
          <Box className="codeBox" key={mixnode.bond_information.mix_id}>
            <span
              style={{ marginRight: "1rem" }}
            >{`id: ${mixnode.bond_information.mix_id}`}</span>
            <span>{`owner: ${mixnode.bond_information.owner}`}</span>
          </Box>
        ))}
    </div>
  );
};