Phantom Developer Docs
HomeDeveloper Forums
  • 👻Introduction
    • Introduction
  • 🟩Solana
    • Getting Started With Solana
    • Detecting the Provider
    • Establishing a Connection
    • Sending a Legacy Transaction
    • Sending a Versioned Transaction
    • Signing a Message
    • Error Messages and Codes
  • 🔷Ethereum, Monad Testnet, Base, & Polygon
    • Getting Started with EVM networks
    • Detecting the Provider
    • Establishing a Connection
    • Sending a Transaction
    • Signing a Message
    • Provider API Reference
      • Properties
        • isPhantom
        • chainId
        • networkVersion
        • selectedAddress
        • _events
        • _eventsCount
      • Events
        • Connect
        • Accounts Changed
        • Disconnect
        • Chain Changed
      • Methods
        • isConnected
        • request
      • Error Messages & Codes
  • 🌊Sui
    • Getting Started with Sui
    • Detecting the Provider
    • Establishing a Connection
    • Sending a Transaction
    • Signing a Message
  • 🟠Bitcoin
    • Getting Started With Bitcoin
    • Detecting the Provider
    • Establishing a Connection
    • Sending a Transaction
    • Signing a Message
    • Provider API Reference
  • ⛓️Phantom Deeplinks
    • Phantom Deeplinks
    • Provider Methods
      • Connect
      • Disconnect
      • SignAndSendTransaction
      • SignAllTransactions
      • SignTransaction
      • SignMessage
    • Other Methods
      • Browse
      • Fungible
      • Swap
    • Handling Sessions
    • Specifying Redirects
    • Encryption
    • Limitations
  • 🛠️Developer Powertools
    • Auto-Confirm
    • Domain and Transaction Warnings
    • Mobile Web Debugging
    • Phantom Blocklist
    • Shortcuts
    • Sign-In-With (SIW) Standards
    • Solana Actions & Blinks
    • Solana Priority Fees
    • Solana Token Extensions (Token22)
    • Solana Versioned Transactions
    • Testnet Mode
    • Token Pages
    • Wallet Standard
  • ✅Best Practices
    • Launching a Dapp
    • Displaying Apps within the Activity Tab
    • Displaying Apps within Dialogs
    • Displaying Tokens on Solana
      • Fungibles
      • NFTs & Semi-Fungibles
      • Supported Media Types
  • 🙋Resources
    • FAQ
    • Demo Applications
    • Community Guides & SDKs
    • Logos & Assets
Powered by GitBook
On this page

Was this helpful?

  1. Ethereum, Monad Testnet, Base, & Polygon
  2. Provider API Reference
  3. Methods

request

Sends a JSON RPC request to the wallet

PreviousisConnectedNextError Messages & Codes

Last updated 2 years ago

Was this helpful?

Params: method: string; params?: unknown[] | object;

Returns: Promise<unknown>

Example:

const accounts = await window.phantom.ethereum.request({ 
    method: "eth_requestAccounts", params: [] 
})
console.log(accounts)
// ["0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5"]

The code above demonstrates how you can use the request method to ask the user to connect to your dapp. The request method is the go to way for you to interface with the wallet in your dapp. It accepts most that would need to interact with the wallet. However it will not work for methods that don't make sense for a wallet. E.g. you can't use the provider object Phantom injects to call something like eth_getTransactionByHash. If you send a method that the provider object does not support, it will throw an error. You can see a list of errors, and the shape that they will take on page.

🔷
JSON RPC requests
this