Nimiq
API Reference

Ethereum Provider API

Reference for the EIP-1193 Ethereum provider injected into mini apps, including EIP-6963 compatibility

This provider implements EIP-1193 and supports EIP-6963 provider discovery. It is injected into the mini app environment.

Access

JavaScript
const provider = window.ethereum

Methods

eth_requestAccounts / requestAccounts

Requests the user's Ethereum accounts.

Parameters

  • none

Returns

  • string[] — Ethereum addresses.

User confirmation

  • yes

Example

JavaScript
const accounts = await provider.request({ method: 'eth_requestAccounts' })

personal_sign / signPersonalMessage

Signs a message with the user's Ethereum key.

Parameters

  • data (string, required): message to sign, plain text or hex string (0x-prefixed).
  • address (string, required): Ethereum address to sign with.

Returns

  • string — hex signature.

User confirmation

  • yes

Example

JavaScript
const signature = await provider.request({
  method: 'personal_sign',
  params: ['hello', '0x1234567890abcdef1234567890abcdef12345678'],
})

eth_sendTransaction

Submits a transaction for signing and broadcasting.

Parameters

  • from (string, required): sender address.
  • to (string, required): recipient address or contract address.
  • value (string, optional): hex-encoded amount of native token to send (in wei).
  • data (string, optional): hex-encoded contract call data.
  • gas (string, optional): hex-encoded gas limit.

Returns

  • string — transaction hash.

User confirmation

  • yes

Example

JavaScript
const txHash = await provider.request({
  method: 'eth_sendTransaction',
  params: [{
    from: '0x1234567890abcdef1234567890abcdef12345678',
    to: '0x1234567890abcdef1234567890abcdef12345678',
    value: '0x0',
    data: '0x',
  }],
})

eth_signTypedData_v4

Signs typed structured data. Unlike personal_sign, this method presents the user with a readable breakdown of the data being signed, making it suitable for permits, order approvals, or login challenges. This is the current recommended signing method. The data structure follows the EIP-712 standard. See the MetaMask signing guide for more context on signing methods.

Parameters

  • address (string, required): Ethereum address to sign with.
  • typedData (string, required): JSON-stringified object containing domain, types, primaryType, and message.

Returns

  • string — hex signature.

User confirmation

  • yes

Example

JavaScript
const signature = await provider.request({
  method: 'eth_signTypedData_v4',
  params: [
    '0x1234567890abcdef1234567890abcdef12345678',
    JSON.stringify({
      domain: { name: 'My App', version: '1', chainId: 137 },
      types: { Message: [{ name: 'content', type: 'string' }] },
      primaryType: 'Message',
      message: { content: 'Hello' },
    }),
  ],
})

wallet_switchEthereumChain / switchEthereumChain

Switches the active Ethereum network.

Parameters

  • chainId (string, required): hex chain id.

Returns

  • null.

Errors

  • 4902 — chain not configured.

User confirmation

  • yes

Example

JavaScript
await provider.request({
  method: 'wallet_switchEthereumChain',
  params: [{ chainId: '0x89' }],
})

wallet_addEthereumChain / addEthereumChain

Adds a new chain configuration and switches to it.

Parameters

  • chainId (string, required): hex chain id.
  • chainName (string, required): human-readable name.
  • rpcUrls (string, required): RPC endpoints (first used).
  • nativeCurrency (object, optional): { name: string, symbol: string, decimals: number }.
  • blockExplorerUrls (string, optional): block explorer URLs.

Returns

  • null.

User confirmation

  • yes

Example

JavaScript
await provider.request({
  method: 'wallet_addEthereumChain',
  params: [{
    chainId: '0x89',
    chainName: 'Polygon',
    rpcUrls: ['https://polygon-bor-rpc.publicnode.com'],
    nativeCurrency: { name: 'MATIC', symbol: 'MATIC', decimals: 18 },
    blockExplorerUrls: ['https://polygonscan.com'],
  }],
})

rpcCall

Proxies a JSON-RPC call through the host app.

Parameters

  • rpcUrl (string, required): RPC endpoint URL.
  • payload (object, required): JSON-RPC request payload.

Returns

  • JSON-RPC response.

User confirmation

  • no

Example

JavaScript
const response = await provider.request({
  method: 'rpcCall',
  params: {
    rpcUrl: 'https://ethereum-rpc.publicnode.com',
    payload: { jsonrpc: '2.0', id: 1, method: 'eth_chainId', params: [] },
  },
})

Standard JSON-RPC Methods

These methods are routed through rpcCall.

eth_chainId

Returns the current chain id.

Parameters

  • none

Returns

  • string — hex quantity.

User confirmation

  • no

Example

JavaScript
const chainId = await provider.request({ method: 'eth_chainId' })

eth_accounts

Returns the connected accounts.

Parameters

  • none

Returns

  • string[] — Ethereum addresses (empty if not connected).

User confirmation

  • no

Example

JavaScript
const accounts = await provider.request({ method: 'eth_accounts' })

eth_getBalance

Returns the balance for an address.

Parameters

  • address (string, required): Ethereum address.
  • block (string, required): block tag or hex block number.

Returns

  • string — hex quantity.

User confirmation

  • no

Example

JavaScript
const balance = await provider.request({
  method: 'eth_getBalance',
  params: ['0x1234567890abcdef1234567890abcdef12345678', 'latest'],
})

eth_call

Executes a read-only contract call.

Parameters

  • tx (object, required): transaction call object.
  • block (string, required): block tag or hex block number.

Returns

  • string — hex data.

User confirmation

  • no

Example

JavaScript
const data = await provider.request({
  method: 'eth_call',
  params: [{ to: '0x1234567890abcdef1234567890abcdef12345678', data: '0x' }, 'latest'],
})

eth_estimateGas

Estimates gas for a transaction.

Parameters

  • tx (object, required): transaction call object.

Returns

  • string — hex quantity.

User confirmation

  • no

Example

JavaScript
const gas = await provider.request({
  method: 'eth_estimateGas',
  params: [{ to: '0x1234567890abcdef1234567890abcdef12345678', data: '0x' }],
})

eth_gasPrice

Returns the current gas price.

Parameters

  • none

Returns

  • string — hex quantity.

User confirmation

  • no

Example

JavaScript
const gasPrice = await provider.request({ method: 'eth_gasPrice' })

eth_getTransactionCount

Returns the nonce for an address.

Parameters

  • address (string, required): Ethereum address.
  • block (string, required): block tag or hex block number.

Returns

  • string — hex quantity.

User confirmation

  • no

Example

JavaScript
const nonce = await provider.request({
  method: 'eth_getTransactionCount',
  params: ['0x1234567890abcdef1234567890abcdef12345678', 'latest'],
})

eth_getTransactionReceipt

Returns the transaction receipt.

Parameters

  • txHash (string, required): 0x-prefixed 32-byte hash.

Returns

  • object | nullnull if not mined.

User confirmation

  • no

Example

JavaScript
const receipt = await provider.request({
  method: 'eth_getTransactionReceipt',
  params: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
})

eth_blockNumber

Returns the latest block number.

Parameters

  • none

Returns

  • string — hex quantity.

User confirmation

  • no

Example

JavaScript
const blockNumber = await provider.request({ method: 'eth_blockNumber' })

eth_getBlockByNumber

Returns block information for a given block.

Parameters

  • block (string, required): block tag or hex block number.
  • includeTxs (boolean, required): include full transaction objects.

Returns

  • object | nullnull if not found.

User confirmation

  • no

Example

JavaScript
const block = await provider.request({
  method: 'eth_getBlockByNumber',
  params: ['latest', false],
})

eth_getLogs

Returns logs matching a filter.

Parameters

  • filter (object, required): log filter object.

Returns

  • object[] — log objects.

User confirmation

  • no

Example

JavaScript
const logs = await provider.request({
  method: 'eth_getLogs',
  params: [{ fromBlock: 'latest' }],
})

net_version

Returns the current network id.

Parameters

  • none

Returns

  • string — decimal network id.

User confirmation

  • no

Example

JavaScript
const networkId = await provider.request({ method: 'net_version' })

For a practical guide to reading ERC-20 token balances and sending token transfers through this provider, see Using EVM Tokens in Mini Apps.

EIP-6963 Provider Discovery

Nimiq Pay is EIP-6963 compatible and discoverable by wallet discovery flows that support EIP-6963.

Mini app developers do not need to manually announce the provider. In most cases, using window.ethereum or a standard EIP-6963-compatible discovery library is sufficient.

Copyright © 2026