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:
| State | Description |
|---|---|
disconnected | Initial state with no active provider |
connecting | SDK initializing the provider |
connected | NeroProvider ready for requests |
errored | Initialization 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 Field | Purpose | Internal Mapping |
|---|---|---|
chainId | Active chain ID | this._chainId |
getAccounts | Retrieve addresses | this.getAccounts() |
signMessage | Sign bytes | this.signMessageInternal() |
signTypedData | Sign EIP-712 data | this.signTypedDataInternal() |
sendTransaction | Process transactions | this.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'ssignMessageInternaleth_signTypedData_v4-- Parses JSON typed data and forwards tosignTypedDataInternal
Transaction Execution
eth_sendTransaction triggers protocol-specific workflows. Pedersen builds ERC-4337 UserOperations, while DKLS generates signatures for raw transactions.
Provider Events
| Event | Trigger | Data |
|---|---|---|
connect | Provider becomes active | ProviderConnectInfo (hex chainId) |
disconnect | Provider deactivated | ProviderRpcError |
chainChanged | Chain switch | string (hex chainId) |
accountsChanged | Wallet generated/cleared | string[] |
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
| Code | Name | Description |
|---|---|---|
| 4001 | USER_REJECTED | User rejected request |
| 4100 | UNAUTHORIZED | Provider lacks authorization |
| 4200 | UNSUPPORTED_METHOD | RPC method not implemented |
| 4900 | DISCONNECTED | Provider disconnected from chain |
| 4902 | CHAIN_NOT_ADDED | Requested chain not added |
SDK Integration Methods
Three helper methods manage the provider lifecycle:
| Method | Description |
|---|---|
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),
});