NERO

EIP-1193 Provider

Standards-compliant Ethereum provider for dApp integration

EIP-1193 Provider

The NeroProvider class implements the EIP1193Provider interface, creating a standards-compliant Ethereum provider that delegates RPC methods to the SDK's internal MPC operations. This adapter enables seamless integration with any dApp or library that accepts a standard Ethereum provider.

Connection Lifecycle

The SDK manages provider connectivity through a state machine tracking four distinct states:

StateDescription
disconnectedInitial state with no active provider
connectingSDK initializing the provider
connectedNeroProvider ready for requests
erroredInitialization failure occurred

The status getter exposes current connection state, with a connected boolean shorthand for convenience.

Provider Configuration

The NeroProvider receives request({ method, params }) calls and routes them to internal SDK callbacks:

Config FieldPurposeInternal Mapping
chainIdActive chain IDthis._chainId
getAccountsRetrieve addressesthis.getAccounts()
signMessageSign bytesthis.signMessageInternal()
signTypedDataSign EIP-712 datathis.signTypedDataInternal()
sendTransactionProcess transactionsthis.sendTransactionInternal()

Key RPC Handlers

Account Management

eth_accounts and eth_requestAccounts return the active wallet address. DKLS mode returns _dklsWalletAddress, while Pedersen returns the EOA address from the SmartWallet instance.

Message Signing

  • personal_sign -- Converts hex or UTF-8 messages to bytes before calling the SDK's signMessageInternal
  • eth_signTypedData_v4 -- Parses JSON typed data and forwards to signTypedDataInternal

Transaction Execution

eth_sendTransaction triggers protocol-specific workflows. Pedersen builds ERC-4337 UserOperations, while DKLS generates signatures for raw transactions.

Provider Events

EventTriggerData
connectProvider becomes activeProviderConnectInfo (hex chainId)
disconnectProvider deactivatedProviderRpcError
chainChangedChain switchstring (hex chainId)
accountsChangedWallet generated/clearedstring[]
sdk.provider.on("connect", (info) => {
  console.log("Connected to chain:", info.chainId);
});

sdk.provider.on("disconnect", (error) => {
  console.log("Disconnected:", error);
});

sdk.provider.on("accountsChanged", (accounts) => {
  console.log("Accounts:", accounts);
});

sdk.provider.on("chainChanged", (chainId) => {
  console.log("Chain changed:", chainId);
});

Provider Error Codes

CodeNameDescription
4001USER_REJECTEDUser rejected request
4100UNAUTHORIZEDProvider lacks authorization
4200UNSUPPORTED_METHODRPC method not implemented
4900DISCONNECTEDProvider disconnected from chain
4902CHAIN_NOT_ADDEDRequested chain not added

SDK Integration Methods

Three helper methods manage the provider lifecycle:

MethodDescription
getProvider()Returns current EIP1193Provider
connect()Initializes provider and transitions to connected state
disconnect()Cleans up provider and transitions to disconnected state

The provider becomes fully operational after the connection state transitions to "connected", enabling dApps to submit RPC requests through any compatible library.

Usage with ethers.js

import { BrowserProvider } from "ethers";

const ethersProvider = new BrowserProvider(sdk.provider);
const signer = await ethersProvider.getSigner();
const balance = await ethersProvider.getBalance(signer.address);

Usage with viem

import { createWalletClient, createPublicClient, custom } from "viem";
import { neroTestnet } from "@nerochain/mpc-sdk/chains";

const walletClient = createWalletClient({
  chain: neroTestnet,
  transport: custom(sdk.provider),
});

const publicClient = createPublicClient({
  chain: neroTestnet,
  transport: custom(sdk.provider),
});

On this page