Onyx Constructor

Creates an instance of the Onyx.js SDK.

  • [provider] (Provider | string) Optional Ethereum network provider. Defaults to Ethers.js fallback mainnet provider.

  • [options] (object) Optional provider options.

  • RETURN (object) Returns an instance of the Onyx.js SDK.

const onyx = new Onyx(window.ethereum); // web browser

const onyx = new Onyx('http://127.0.0.1:8545'); // HTTP provider

const onyx = new Onyx(); // Uses Ethers.js fallback mainnet (for testing only)

const onyx = new Onyx('goerli'); // Uses Ethers.js fallback (for testing only)

// Init with private key (server side)
const onyx = new Onyx('https://mainnet.infura.io/v3/_your_project_id_', {
  privateKey: '0x_your_private_key_', // preferably with environment variable
});

// Init with HD mnemonic (server side)
const onyx = new Onyx('mainnet' {
  mnemonic: 'clutch captain shoe...', // preferably with environment variable
});

Last updated