Skip to main content

HolographConfig

The HolographConfig object is used to configure the initial setup of the SDK to connect to blockchain networks, sign transactions, deploy contracts, mint tokens, bridge tokens, and interact with additional features across Holograph Protocol.

1. Properties

type HolographConfig = {
accounts?: AccountsConfig;
networks?: NetworkRpc;
environment?: Environment;
};

accounts

  • Type:
    { default: HolographAccount, [accountName: string]: HolographAccount }

The accounts object is used to configure the accounts the SDK will use to sign transactions. It contains the default and additional accounts to use with the SDK transactions.

Use the HolographAccountFactory to create accounts using a private key, a mnemonic, or an EIP-1193 provider. For more information, check out the HolographAccountFactory class reference.

src/holograph/accounts.ts
import { HolographAccountFactory } from "@holographxyz/sdk";

export const accounts = {
default: HolographAccountFactory.createAccountUsingPrivateKey(
process.env.DEFAULT_ACCOUNT_PRIVATE_KEY
),
accountAbc: HolographAccountFactory.createAccountUsingPrivateKey(
process.env.ACCOUNT_ABC_PRIVATE_KEY
),
accountXyz: HolographAccountFactory.createAccountUsingPrivateKey(
process.env.ACCOUNT_XYZ_PRIVATE_KEY
),
};

networks

  • Type:
    { [key in NetworkKey]?: string }

The networks object is used to configure the network RPC URLs the SDK will use to connect to different blockchains. The key is the network name key and the value is the RPC URL.

src/holograph/networks.ts
export const networks = {
polygon: "https://polygon-rpc-url.com",
avalanche: "https://avalanche-rpc-url.com",
};

Here is the full list of supported mainnet network keys:

  • ethereum
  • polygon
  • avalanche
  • binanceSmartChain
  • arbitrumOne
  • base
  • linea
  • mantle
  • optimism
  • zora

Here is the full list of supported testnet network keys:

  • ethereumTestnetSepolia
  • polygonTestnet
  • avalancheTestnet
  • binanceSmartChainTestnet
  • lineaTestnetGoerli
  • lineaTestnetSepolia
  • arbitrumTestnetSepolia
  • baseTestnetSepolia
  • mantleTestnet
  • mantleTestnetSepolia
  • optimismTestnetSepolia
  • seiTestnetArctic
  • zoraTestnetSepolia

The networks property can be skipped as long as the .env file contains the network RPC URLs.

.env
POLYGON_RPC_URL = "https://polygon-rpc-url.com";
AVALANCHE_RPC_URL = "https://avalanche-rpc-url.com";

Here is the full list of supported mainnet network RPC URLs:

  • ETHEREUM_RPC_URL
  • POLYGON_RPC_URL
  • AVALANCHE_RPC_URL
  • BINANCE_SMART_CHAIN_RPC_URL
  • ARBITRUM_ONE_RPC_URL
  • BASE_RPC_URL
  • LINEA_RPC_URL
  • MANTLE_RPC_URL
  • OPTIMISM_RPC_URL
  • ZORA_RPC_URL

Here is the full list of supported testnet network RPC URLs:

  • ETHEREUM_TESTNET_SEPOLIA_RPC_URL
  • POLYGON_TESTNET_RPC_URL
  • AVALANCHE_TESTNET_RPC_URL
  • BINANCE_SMART_CHAIN_TESTNET_RPC_URL
  • LINEA_TESTNET_GOERLI_RPC_URL
  • LINEA_TESTNET_SEPOLIA_RPC_URL
  • ARBITRUM_TESTNET_SEPOLIA_RPC_URL
  • BASE_TESTNET_SEPOLIA_RPC_URL
  • MANTLE_TESTNET_RPC_URL
  • MANTLE_TESTNET_SEPOLIA_RPC_URL
  • OPTIMISM_TESTNET_SEPOLIA_RPC_URL
  • SEI_TESTNET_ARCTIC_RPC_URL
  • ZORA_TESTNET_SEPOLIA_RPC_URL

environment

  • Type:
    localhost | experimental | develop | testnet | mainnetdefault: testnet

The environment property is used to configure the environment to use with the SDK.

It is an enum with the following shape:

export enum Environment {
localhost = "localhost",
experimental = "experimental",
develop = "develop",
testnet = "testnet",
mainnet = "mainnet",
}

Make sure to import it from the @holographxyz/environment package.

src/holograph/environment.ts
import { Environment } from "@holographxyz/environment";

export const environment = Environment.mainnet;

2. Example

Here is an example with all the properties set:

src/holograph/config.ts
import { HolographAccountFactory, HolographConfig } from "@holographxyz/sdk";
import { Environment } from "@holographxyz/environment";

export const holographConfig: HolographConfig = {
networks: {
polygon: "https://your-polygon-rpc-url.com",
avalanche: "https://your-avalanche-rpc-url.com",
},
environment: Environment.mainnet,
accounts: {
default: HolographAccountFactory.createAccountUsingPrivateKey(
process.env.PRIVATE_KEY
),
},
};