React library to make interaction with Sui wallets easy
Wallets supported:
- Sui
npm install react-sui-wallets
- wallets: WalletType[] - wallets that app will support
import { WalletProvider, WalletType } from 'react-sui-wallets';
export const App = () => (
<WalletProvider
wallets={[WalletType.Sui]}
>
// other components...
</WalletProvider>
);
- connect: (walletType: WalletType) => void - tries connect to provided wallet
- signAndSubmitTransaction: (tx: MoveCallTransaction): Promise<TransactionResponse> - submits provided transaction
- isConnected: () => boolean
- accounts: SuiAddress[]
import { useWallet, WalletType } from 'react-sui-wallets';
export const App = () => {
const { isConnected, connect, accounts } = useWallet();
return (
<div>
{isConnected()
? accounts[0]
: <button onClick={() => connect(WalletType.Sui)}>Connect wallet</button>}
</div>
);
}