Ronin Modal is a framework agnostic UI library that simplifies the integration of the Ronin Wallet connection with websites.
Ronin Modal supports W3Vm and Wagmi v2.
npm install @roninbuilders/modal
-
Import the chain you want to use, you can select Ronin mainnet or Saigon testnet.
-
Get a free project ID from WalletConnect Cloud. This is used for mobile connection.
-
Call the
createRoninModal
function on top of your application.
import { ronin, saigon, createRoninModal } from "@roninbuilders/modal"
createRoninModal({
chain: saigon,
projectId: "WALLETCONNECT_PROJECT_ID",
})
Now you can call the web component button anywhere in your application. This web component doesn't require importing and its CSS style can be overwritten.
<ronin-button/>
if you are NOT using React.js, you can use the W3Vm Core functions to get the user address and the provider.
Install W3Vm React to use hooks that are connected to the Ronin Modal.
npm install @w3vm/react
Use react hooks to get the wallet provider and address. These values are reactive and depend on the Ronin Modal state.
import './App.css'
import { ronin, saigon, createRoninModal } from "@roninbuilders/modal"
import { getW3Address, getW3Provider } from '@w3vm/react'
createRoninModal({
chain: saigon,
projectId: "WALLETCONNECT_PROJECT_ID",
})
export default function App() {
const address = getW3Address()
const provider = getW3Provider()
console.log(address, provider)
return <ronin-button/>
}
You can wrap the provider with any ethereum library such as Ethers, Viem or Web3js.
If you are using a Meta-frameworks like Next.js with SSR, you can use the SSR flag to avoid hydration mismatch errors.
- Add the SSR param when calling
createRoninModal
- This function will now return an object, we can call it
w3props
(or any name). - Import the
W3
component from W3Vm React and place it on top of your application.
import { saigon, createRoninModal } from "@roninbuilders/modal"
import { W3 } from '@w3vm/react'
const w3props = createRoninModal({
chain: saigon,
projectId: "WALLETCONNECT_PROJECT_ID",
SSR: true,
})
export default function App({ Component, pageProps }: AppProps) {
return (
<>
<W3 {...w3props} /> { /* Required when SSR: true */ }
<Component {...pageProps} />
</>
)
}
pnpm install
pnpm run build
- in the first one type:
cd packages/modal-w3vm
pnpm run watch
or
cd packages/modal-wagmi-v2
pnpm run watch
- in the second terminal run
pnpm run dev:w3vm
or
pnpm run dev:wagmi
Now you can open localhost and see the changes in the package reflected on these examples.