Skip to main content

Ronin Wallet JS SDK

Overview

This page contains a full list of methods and properties provided by the Ronin Wallet JavaScript SDK.

Constructor

You can pass options when constructing a WalletSDK instance.

Example:

const sdk = new WalletSDK({
mobileOptions: {
walletConnectProjectId: 'd2ef97836db7eb390bcb2c1e9847ecdc',
useDeeplink: false
},
dappMetadata: {
url: window.location.origin,
icon: 'https://example-dapp/assets/logo.png',
name: 'Example dApp',
description: 'This is a test dApp',
}
})
Option nameTypeRequiredDescription
dappMetadataDappMetadataoptionalUsed for displaying the dApp's information on the connection popup in Ronin Wallet.
mobileOptionsMobileOptionsoptionalSet these options only if you want to connect to the mobile Ronin Wallet.

Types

dappMetadata

Specifies information you want to display when connecting to Ronin Wallet. If not defined, the data is fetched from HTML by default.

KeyTypeDefault valueRequiredDescription
urlstringrequiredURL of the dApp, similar to window.location.origin.
namestringrequiredTitle of the dApp, similar to document.title.
iconstringoptionalURL of the dApp's logo.
descriptionstringoptionalShort description of the dApp.

MobileOptions

KeyTypeDefault valueRequiredDescription
useDeeplinkbooleanoptionalSet it to true if you want to use a deep link instead of a universal link.
walletConnectProjectIdstringrequiredThis is mandatory if you want to connect to the mobile Ronin Wallet. Check WalletConnect instruction on how to obtain a project ID.

InitialData

Response data after connecting.

KeyTypeDefault valueRequiredDescription
accountsstring[]requiredList of approved accounts.
chainIdnumberrequiredCurrent chain ID in Ronin Wallet.

Methods

connectMobile()

connectMobile(): Promise<InitialData>

Emits an event when connection is ready. You must provide mobileOptions before calling this method.

connectInjected()

connectInjected(): Promise<InitialData>

May return an empty array if the wallet is locked. If you want the extension popup to show, use requestAccounts.

connect()

connect(): Promise<InitialData>

Automatically initializes connection based on the environment.

getDeeplink(): string | undefined

Returns a deep link or universal link based on the provided mobileOptions.useDeeplink.

You must call this method after connectMobile() is called and WCEvent.DISPLAY_URI is emitted.

disconnect()

disconnect(): Promise<void>

Disconnects the current session and cleans up.

requestAccounts()

requestAccounts(): Promise<string[]>

Returns the approved accounts. If the wallet is locked, an extension popup is displayed.

getAccounts()

getAccounts(): Promise<string[]>

Returns the approved accounts.

getChainId()

getChainId(): Promise<number>

  • Ronin Wallet extension: returns the current chain ID.
  • Ronin Wallet mobile app: returns the chain ID as of the last time the wallet was active.

getProvider()

getProvider(): EIP1193Provider

Returns an instance of EIP1193Provider. This method is useful when you want to make custom requests.

request()

request(args: RequestArguments, autoOpenMobileApp = true): Promise<unknown>

Sends a JsonRpcRequest and opens the Ronin Wallet mobile app automatically when possible.

openMobileApp()

openMobileApp(url: string, target = '_self', autoClose = true'): void

Opens the Ronin Wallet mobile app using a universal link by default.

Was this helpful?
Happy React is loading...