Web3 API Reference

This document provides detailed reference information for developers integrating with Macro Browser's Web3 capabilities.

Provider Object


Macro Browser injects a standard Web3 provider object (window.ethereum) into all pages, following the EIP-1193arrow-up-right specification with some Macro-specific enhancements.

interface MacroProvider {
  // Standard EIP-1193 Properties
  isConnected(): boolean;
  chainId: string;
  selectedAddress: string | null;

  // Standard EIP-1193 Methods
  request(args: RequestArguments): Promise<unknown>;
  on(eventName: string, listener: (arg: any) => void): Provider;
  removeListener(eventName: string, listener: (arg: any) => void): Provider;

  // Macro Browser Specific
  isMacro: boolean;             // Always true, identifies Macro Browser
  isPrivate: boolean;           // Indicates if browser is in private mode (always true)
  securityLevel: 'standard' | 'enhanced'; // Current security settings
}

interface RequestArguments {
  method: string;
  params?: unknown[] | object;
}

Supported JSON-RPC Methods


Basic Methods

Method
Parameters
Return Type
Description

eth_accounts

None

string[]

Returns active accounts

eth_requestAccounts

None

string[]

Requests user permission for account access

eth_chainId

None

string

Returns current chain ID in hex

eth_blockNumber

None

string

Returns latest block number in hex

eth_getBalance

[address, blockTag]

string

Returns account balance

eth_sendTransaction

[transactionObject]

string

Sends a transaction

eth_call

[transactionObject, blockTag]

string

Executes a call without creating a transaction

eth_estimateGas

[transactionObject]

string

Estimates gas needed for transaction

eth_gasPrice

None

string

Returns current gas price

eth_getTransactionCount

[address, blockTag]

string

Returns account nonce

eth_getCode

[address, blockTag]

string

Returns contract code at address

eth_getStorageAt

[address, position, blockTag]

string

Returns value in contract storage

eth_getTransactionByHash

[txHash]

Object

Returns transaction details

eth_getTransactionReceipt

[txHash]

Object

Returns transaction receipt

Signing Methods

Method
Parameters
Return Type
Description

eth_sign

[address, message]

string

Signs a message (legacy)

personal_sign

[message, address]

string

Signs a personal message

eth_signTypedData

[address, typedData]

string

Signs typed data (legacy)

eth_signTypedData_v4

[address, typedData]

string

Signs typed data (current)

eth_signTransaction

[transactionObject]

Object

Signs without sending

Chain Management

Method
Parameters
Return Type
Description

wallet_switchEthereumChain

[{ chainId }]

None

Switches to specified chain

wallet_addEthereumChain

[chainObject]

None

Adds new chain definition

wallet_getPermissions

None

Object[]

Returns current permissions

wallet_requestPermissions

[{ eth_accounts }]

Object[]

Requests permissions

Macro-Specific Methods

Method
Parameters
Return Type
Description

macro_getVersion

None

string

Returns Macro Browser version

macro_getSecurityLevel

None

string

Gets current security level

macro_analyzeTransaction

[transactionObject]

Object

Analyzes transaction risk

macro_isVpnEnabled

None

boolean

Checks if VPN is active

Provider Events


Developers can subscribe to events from the provider:

Transaction Objects


Transaction objects have the following structure:

Chain Objects


When adding new chains, the following structure is used:

Security Considerations


Transaction Analysis

Macro Browser performs advanced transaction analysis for user safety:

Permissions

Always check for permissions before attempting operations:

Error Handling


Macro Browser provides detailed error codes. Handle common errors properly:

Usage Examples


Connecting to a dApp

Contract Interaction

Transaction with Confirmation

Compatibility Notes


Browser Differences

Macro Browser implements the same provider API as MetaMask with some differences:

  • All accounts are treated as "read-only" by default for security

  • Contains extra security checks for potentially risky operations

  • Provides additional methods for transaction analysis

  • No support for legacy methods that have security implications

Feature Detection

Always use feature detection instead of browser detection:

Last updated