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 name | Type | Required | Description |
---|---|---|---|
dappMetadata | DappMetadata | optional | Used for displaying the dApp's information on the connection popup in Ronin Wallet. |
mobileOptions | MobileOptions | optional | Set 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.
Key | Type | Default value | Required | Description |
---|---|---|---|---|
url | string | required | URL of the dApp, similar to window.location.origin . | |
name | string | required | Title of the dApp, similar to document.title . | |
icon | string | optional | URL of the dApp's logo. | |
description | string | optional | Short description of the dApp. |
MobileOptions
Key | Type | Default value | Required | Description |
---|---|---|---|---|
useDeeplink | boolean | optional | Set it to true if you want to use a deep link instead of a universal link. | |
walletConnectProjectId | string | required | This 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.
Key | Type | Default value | Required | Description |
---|---|---|---|---|
accounts | string[] | required | List of approved accounts. | |
chainId | number | required | Current 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()
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.