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. Sui

Detecting the Provider

PreviousGetting Started with SuiNextEstablishing a Connection

Last updated 2 months ago

Was this helpful?

To detect if a user has already installed Phantom, a web application should check for the existence of a phantom object. Phantom's browser extension and mobile in-app browser will both inject a phantom object into the of any web application the user visits, provided that site is using https://, on localhost, or is 127.0.0.1. Phantom will not inject the provider into sites using http://.

If a phantom object exists, Sui apps can interact with Phantom via the API found at window.phantom.sui.

To detect if Phantom is installed, an application should check for an additional isPhantom flag.

const isPhantomInstalled = window.phantom?.sui?.isPhantom

If Phantom is not installed, we recommend you redirect your users to . Altogether this may look like the following.

const getProvider = () => {
  if ('phantom' in window) {
    const provider = window.phantom?.sui;

    if (provider?.isPhantom) {
      return provider;
    }
  }
  window.open('https://phantom.com/', '_blank');
};

🌊
window
our website