Management API Reference

Ecosystem wallet

Create wallet button

For the best onboarding experience, we recommend adding a highly visible 'Create' or 'Create Wallet' button to your app's homepage. Adding this button streamlines the onboarding experience for new users and gets them ready to use your app in a few seconds.

Here is an example of how the button looks:

create-wallet-button

Implementation with Wagmi#

To make these instructions concrete, we have created a sample ecosystem wallet called Rapidfire ID. To interact with it, you can find its SDK in the NPM package directory: @rapidfire/id.

You can check out the GitHub repository for Rapidfire Wallet to learn how to create your own wallet.

Using Wagmi offers a balanced approach that combines flexibility with developer convenience. By integrating the ecosystem wallet with Wagmi, you get access to a comprehensive set of React hooks that handle common wallet operations, state management, and chain interactions. This approach requires both @rapidfire/id and Wagmi dependencies, along with React Query, but provides a more structured development experience. While you'll still need to build your own UI components, Wagmi's hooks significantly reduce the complexity of handling wallet connections, transactions, and chain switching.

1

Configure Wagmi

First, set up your Wagmi configuration with the required chain and connector settings.

wagmi.ts

_19
import { http, createConfig } from 'wagmi';
_19
import { polygonAmoy } from 'wagmi/chains';
_19
import { injected } from 'wagmi/connectors';
_19
_19
export const config = createConfig({
_19
chains: [polygonAmoy],
_19
connectors: [
_19
injected(),
_19
],
_19
transports: {
_19
[polygonAmoy.id]: http(),
_19
},
_19
});
_19
_19
declare module 'wagmi' {
_19
interface Register {
_19
config: typeof config;
_19
}
_19
}

2

Create the Wallet Logo Component

Create a reusable wallet logo component that will be used in the button.

WalletLogo.tsx

_39
import React from 'react';
_39
_39
const defaultContainerStyles = {
_39
paddingTop: 2,
_39
display: 'flex',
_39
alignItems: 'center',
_39
};
_39
_39
export function WalletLogo({
_39
size = 24,
_39
containerStyles = defaultContainerStyles,
_39
}) {
_39
return (
_39
<div style={containerStyles}>
_39
<svg
_39
width={size}
_39
height={size}
_39
viewBox="0 0 24 24"
_39
fill="none"
_39
xmlns="http://www.w3.org/2000/svg"
_39
>
_39
<rect
_39
x="2"
_39
y="4"
_39
width="20"
_39
height="16"
_39
rx="3"
_39
stroke="currentColor"
_39
strokeWidth="2"
_39
/>
_39
<path
_39
d="M16 12C16 10.8954 16.8954 10 18 10H22V14H18C16.8954 14 16 13.1046 16 12Z"
_39
fill="currentColor"
_39
/>
_39
<circle cx="12" cy="12" r="2" fill="currentColor" />
_39
</svg>
_39
</div>
_39
);
_39
}

3

Implement the Create Wallet Button

Create the main button component using Wagmi's useConnect hook.

CreateWalletButton.tsx

_47
import React, { useCallback } from 'react';
_47
import { useConnect } from 'wagmi';
_47
import { WalletLogo } from './WalletLogo';
_47
_47
const buttonStyles = {
_47
background: 'linear-gradient(135deg, #2D3436 0%, #000000 100%)',
_47
border: '1px solid rgba(255, 255, 255, 0.1)',
_47
boxSizing: 'border-box' as const,
_47
display: 'flex',
_47
alignItems: 'center',
_47
gap: '12px',
_47
width: 'auto',
_47
minWidth: '200px',
_47
fontFamily: 'Inter, system-ui, sans-serif',
_47
fontWeight: '600',
_47
fontSize: '16px',
_47
color: '#FFFFFF',
_47
padding: '12px 20px',
_47
borderRadius: '12px',
_47
cursor: 'pointer',
_47
transition: 'all 0.2s ease-in-out',
_47
boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
_47
':hover': {
_47
transform: 'translateY(-1px)',
_47
boxShadow: '0 6px 8px -1px rgba(0, 0, 0, 0.1), 0 4px 6px -1px rgba(0, 0, 0, 0.06)',
_47
},
_47
};
_47
_47
export function CreateWalletButton() {
_47
const { connectors, connect, data } = useConnect();
_47
_47
const createWallet = useCallback(() => {
_47
const injectedConnector = connectors.find(
_47
(connector) => connector.id === 'injected'
_47
);
_47
if (injectedConnector) {
_47
connect({ connector: injectedConnector });
_47
}
_47
}, [connectors, connect]);
_47
_47
return (
_47
<button style={buttonStyles} onClick={createWallet}>
_47
<WalletLogo />
_47
Create Wallet
_47
</button>
_47
);
_47
}

Notes

For more detail, view the useConnect documentation. Upon successful connection, account information can be accessed via data returned from useConnect, or via useAccount.

Implementation with EIP-1193 Provider#

The EIP-1193 Provider approach gives you the most granular control over your ecosystem wallet integration by directly using the SDK's Ethereum provider. This method requires only the @rapidfire/id package and allows you to build everything from scratch. You'll handle all wallet interactions through the standard EIP-1193 provider interface, giving you complete flexibility in implementing wallet creation, connection flows, and transaction handling. While this approach requires more custom development work, it's ideal for applications that need specialized wallet interactions or want to minimize dependencies.

To make these instructions concrete, we have created a sample ecosystem wallet called Rapidfire ID. To interact with it, you can find its SDK in the NPM package directory: @rapidfire/id.

You can check out the GitHub repository for Rapidfire Wallet to learn how to create your own wallet.

1

Initialize the SDK

Create a new SDK instance with your application configuration.

sdk.ts

_10
import EcosystemWallet from '@rapidfire/id';
_10
_10
// Initialize the SDK with required parameters
_10
export const sdk = new EcosystemWallet({
_10
appChainIds: [80002],
_10
appLogoUrl: 'https://a.rgbimg.com/users/b/ba/barunpatro/600/mf6B5Gq.jpg',
_10
appName: 'Example App',
_10
});

2

Set up the Provider

Configure the Ethereum provider with chain and policy settings.

Make sure to set up your NEXT_PUBLIC_POLICY_ID in your environment variables.

provider.ts

_10
import { sdk } from './sdk';
_10
_10
// Configure the provider with chain and policy
_10
export const provider = sdk.getEthereumProvider({
_10
policy: process.env.NEXT_PUBLIC_POLICY_ID
_10
});

3

Implement the Create Wallet Button

Create the button component that uses the configured provider.

CreateWalletButton.tsx

_47
import React, { useCallback } from 'react';
_47
import { WalletLogo } from './WalletLogo';
_47
import { provider } from './provider';
_47
_47
const buttonStyles = {
_47
background: 'linear-gradient(135deg, #2D3436 0%, #000000 100%)',
_47
border: '1px solid rgba(255, 255, 255, 0.1)',
_47
boxSizing: 'border-box' as const,
_47
display: 'flex',
_47
alignItems: 'center',
_47
gap: '12px',
_47
width: 'auto',
_47
minWidth: '200px',
_47
fontFamily: 'Inter, system-ui, sans-serif',
_47
fontWeight: '600',
_47
fontSize: '16px',
_47
color: '#FFFFFF',
_47
padding: '12px 20px',
_47
borderRadius: '12px',
_47
cursor: 'pointer',
_47
transition: 'all 0.2s ease-in-out',
_47
boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
_47
':hover': {
_47
transform: 'translateY(-1px)',
_47
boxShadow: '0 6px 8px -1px rgba(0, 0, 0, 0.1), 0 4px 6px -1px rgba(0, 0, 0, 0.06)',
_47
},
_47
};
_47
_47
export function CreateWalletButton({ handleSuccess, handleError }) {
_47
const createWallet = useCallback(async () => {
_47
try {
_47
const [address] = await provider.request({
_47
method: 'eth_requestAccounts',
_47
});
_47
handleSuccess(address);
_47
} catch (error) {
_47
handleError(error);
_47
}
_47
}, [handleSuccess, handleError]);
_47
_47
return (
_47
<button style={buttonStyles} onClick={createWallet}>
_47
<WalletLogo />
_47
Create Wallet
_47
</button>
_47
);
_47
}