Skip to main content

Installation

npm install @aurum-sdk/core

Configuration Options

The Aurum instance is initialized with the below config options, broken out into brand, wallets, and telemetry.
interface AurumConfig {
  brand?: {
	appName?: string;
	logo?: string;
    theme?: 'light' | 'dark';
    primaryColor?: string;
    borderRadius?: 'none' | 'sm' | 'md' | 'lg' | 'xl';
 	font?: string;
    hideFooter?: boolean; // hides "powered by Aurum" footer
    modalZIndex?: number;
    walletLayout?: 'stacked' | 'grid';
  };
  wallets?: {
    embedded?: {
      projectId: string; // powers email wallet
    };
    walletConnect?: {
      projectId: string; // powers walletconnect & ledger wallets
    };
    exclude?: `${WalletId}`[]; // ['email', 'metamask', ...]
  };
  telemetry?: boolean; // enables error logging through sentry - defaults to `true`
}
Getting Project IDs

Example

const aurum = new Aurum({
  brand: { 
	appName: 'Aurum Demo',
	theme: 'dark',
  },
  wallets: {
	embedded: { projectId: 'cdp-project-id' },
	walletConnect: { projectId: 'reown-project-id' },
  },
});

Aurum Properties

rpcProvider: AurumRpcProvider

EIP-1193 compatible provider. Works with viem, ethers.js, and other web3 libraries.
// Direct RPC request
const accounts = await aurum.rpcProvider.request({ method: 'eth_accounts' });

// With viem
const walletClient = createWalletClient({
  transport: custom(aurum.rpcProvider),
});

// With ethers v6
const provider = new BrowserProvider(aurum.rpcProvider);

// Event listeners
aurum.rpcProvider.on?.('accountsChanged', (accounts: string[]) => { ... });
aurum.rpcProvider.on?.('chainChanged', (chainId: string) => { ... });

Aurum Methods

whenReady(): Promise<void>

Waits for the SDK to finish initializing, including restoring any previous connection, such as after a page refresh.
await aurum.whenReady();

// Safe to use the provider
const balance = await aurum.rpcProvider.request({
  method: "eth_getBalance",
  params: [address, "latest"],
});

connect(walletId?: WalletId): Promise<`0x${string}`>

Opens the wallet connection modal. If walletId is specified, it connects directly to that wallet (see more about Headless UX).
// Show modal
const address = await aurum.connect();

// Connect directly to a specific wallet
import { WalletId } from '@aurum-sdk/types';

const address = await aurum.connect(WalletId.MetaMask);
Available Wallet IDs include WalletId.Email, WalletId.MetaMask, WalletId.Phantom, WalletId.CoinbaseWallet, WalletId.Rabby, WalletId.Brave, WalletId.Ledger, and WalletId.WalletConnect. Throws error if user closes the modal without connecting.

disconnect(): Promise<void>

Disconnects the currently connected wallet.
await aurum.disconnect();

isConnected(): Promise<boolean>

Returns whether a wallet is currently connected.
await aurum.isConnected();

getUserInfo(): Promise<UserInfo | undefined>

Returns info about the connected user, or undefined if not connected.
interface UserInfo {
  publicAddress: string;
  walletName: WalletName;
  walletId: WalletId;
  email?: string;
}

const user = await aurum.getUserInfo();

getChainId(): Promise<string>

Returns the current chain ID.
const chainIdHex = await aurum.getChainId();

switchChain(chainId, chain?): Promise<void>

Switches to a different network. If the chain isn’t added to the wallet, it will attempt to add it.
import { polygon } from 'viem/chains';

await aurum.switchChain(polygon.id, polygon);

updateBrandConfig(newConfig): void

Updates the brand configuration (theme, font, walletLayout, etc).
aurum.updateBrandConfig({ theme: 'light' });

updateWalletsConfig(newConfig): void

Updates the wallets configuration (currently only supports exclude).
aurum.updateWalletsConfig({ exclude: [WalletId.Phantom] });
Using React? See React Hooks API Reference