SDK
keychain-utils

@daohaus/keychain-utils

Keychain utils provide a comprehensive reference point for managing chain-specific DAO data. The package provides an easy way to retrieve a list of constants for any given chain. These constants include contract addresses, API endpoints, The Graph endpoints, and block explorers. The keychain-utils are structured as objects, with chain IDs serving as the keys to these objects.

Github (opens in a new tab)

NPM (opens in a new tab)

Functions

Usage

Installation

yarn add @daohaus/keychain-utils

Examples

How to create a link to the block explorer for an address or transaction

import { generateExplorerLink } from '@daohaus/keychain-utils';
 
const contractLink = generateExplorerLink({
  chainId: '0x1',
  address: '0x0address',
  type: 'address',
});
 
const txLink = generateExplorerLink({
  chainId: '0x5',
  address: '0x0TxHash',
  type: 'tx',
});

How to get contract addresses for each supported network

import { CONTRACT_KEYCHAINS } from '@daohaus/keychain-utils';
 
const vaultSummoner = CONTRACT_KEYCHAINS['VAULT_SUMMONER']['0x1'];

How to get subgraph endpoints for each supported network

import { ENDPOINTS } from '@daohaus/keychain-utils';
 
const arbitrumGraph = ENDPOINTS['V3_SUBGRAPH']['0xa'];
 
const hydratedEndpoints = addApiKeyToGraphEnpoints(
  { '0x1': 'someGraphApiKey' },
  ENDPOINTS
);
const mainnetGraph = hydratedEndpoints['V3_SUBGRAPH']['0x1'];

How to get the name of a network from the ID

import { getNetworkName } from '@daohaus/keychain-utils';
 
const name = getNetworkName('0x64');