NERO
API Reference

NeroMpcSDK Class

Complete API reference for the main SDK class -- constructor, methods, properties, and events

NeroMpcSDK

The NeroMpcSDK class is the primary entry point for the NERO MPC SDK. It orchestrates all subsystems including APIClient for HTTP communication, ClientKeyManager for key storage, protocol-specific clients (DKLSClient or DKGClient), and ChainManager for blockchain configuration.

Constructor

new NeroMpcSDK(config: SDKConfig)

Applies defaults:

  • chainId: 689
  • storagePrefix: "nero"
  • autoConnect: true
  • protocol: "dkls"

Instantiates APIClient, ChainManager, and optionally WebSocketClient (when wsUrl is provided for Pedersen protocol).

Factory Function

createNeroSDK(config: SDKConfig): NeroMpcSDK

Functionally identical to new NeroMpcSDK(config).

Public Properties

PropertyTypeDescription
isAuthenticatedbooleanReturns true when user and valid tokens exist
hasWalletbooleanProtocol-aware check (DKLS: _dklsWalletAddress !== null, Pedersen: _wallet !== null)
connectedbooleanChecks EIP-1193 provider connection status
statusConnectionStatusCurrent connection state: "disconnected", "connecting", "connected", "reconnecting"
userUser | nullCurrent authenticated user; null if not logged in
walletSmartWallet | nullWallet instance (Pedersen only)
chainIdnumberActive chain ID; mutable via switchChain()
providerNeroProvider | nullEIP-1193 provider instance
stateNeroSDKStateSnapshot containing all key state properties

Methods

Initialization

initialize(): Promise<void>

Loads device key, restores session, and initializes wallet. Call this after constructing the SDK.

Authentication

getOAuthUrl(provider: string, redirectUri: string): Promise<{ url: string }>

Returns the OAuth URL and state for the specified provider. Redirect the user to the returned URL.

handleOAuthCallback(provider: string, code: string, state: string): Promise<{ user: User; requiresDKG: boolean }>

Processes the OAuth redirect callback. Returns the authenticated user and whether key generation is needed.

loginWithEmail(email: string): Promise<void>

Sends an OTP or magic link to the specified email address.

verifyEmailLogin(email: string, code: string): Promise<SocialLoginResponse>

Completes email verification with the OTP code.

Wallet Operations

generateWallet(): Promise<WalletInfo>

Triggers the MPC key generation protocol (DKG or DKLS keygen depending on configured protocol). Requires authentication.

getWallets(): Promise<WalletInfo[]>

Retrieves wallet metadata from the backend.

Signing

signMessage(message: string): Promise<string>

Signs a raw message using EIP-191 personal signing prefix.

signTransaction(txParams: TransactionRequest): Promise<string>

Signs a transaction object using the MPC protocol.

signTypedData(domain: object, types: object, value: object): Promise<string>

Signs EIP-712 typed data.

Provider

connect(): Promise<NeroProvider>

Initializes the EIP-1193 provider and transitions to connected state. Returns the provider instance.

disconnect(): Promise<void>

Disconnects the provider and logs out.

getProvider(): NeroProvider

Returns the current EIP-1193 provider instance.

Chain Management

switchChain(chainId: number): Promise<void>

Updates the SDK's active chain. Validates the chain is either built-in or previously added via addChain. Calls notifyListeners to trigger UI updates or provider reconfigurations.

addChain(config: ChainConfig): void

Registers custom networks not included in SDK defaults.

Event System

Methods

MethodDescription
on(event, listener)Register event listener
off(event, listener)Unregister event listener
once(event, listener)Register one-time listener

Events

EventDescription
"initialized"After initialization completion
"login"After successful authentication
"logout"After session clearance
"connected"When EIP-1193 provider is ready
"disconnected"When provider disconnects
sdk.on("login", ({ user }) => {
  console.log(`User logged in: ${user.id}`);
});

sdk.on("connected", ({ chainId }) => {
  console.log(`Connected to chain ${chainId}`);
});

sdk.once("initialized", () => {
  console.log("SDK ready");
});

Dual Protocol Architecture

ProtocolModeKey PropertyUse Case
DKLS (default)2-party threshold ECDSAMultiplicative secret sharingDirect EOA wallet, efficient signing
Pedersen DKGDistributed key generationVerifiable secret sharingSmart account (ERC-4337), multi-party

Protocol selection via config.protocol determines key generation algorithm, signature computation method, and wallet type.

Package Module Structure

Export PathEntry FilePurpose
@nerochain/mpc-sdksrc/index.tsCore SDK class and base types
@nerochain/mpc-sdk/reactsrc/react/index.tsReact context provider and hooks
@nerochain/mpc-sdk/chainssrc/chains/index.tsChain configurations and ChainManager
@nerochain/mpc-sdk/modalsrc/modal/index.tsPre-built UI components
@nerochain/mpc-sdk/no-modalsrc/no-modal/index.tsHeadless SDK for custom UI
@nerochain/mpc-sdk/aasrc/aa/index.tsERC-4337 Smart Account support

Peer Dependencies

Required:

  • @noble/curves ^1.4.0
  • @noble/hashes ^1.4.0

Optional:

  • react ^18.0.0 (for React entry points)
  • ethers ^6.0.0 (for Account Abstraction)
  • @metamask/sdk ^0.20.0 (for MetaMask adapter)

On this page