1.0.0 • Published 2 years ago
react-sui-wallets v1.0.0
React Sui wallets
React library to make interaction with Sui wallets easy
Wallets supported:
- Sui
Installation
npm install react-sui-wallets
Api
WalletProvider
props:
- wallets: WalletType[] - wallets that app will support
Example
import { WalletProvider, WalletType } from 'react-sui-wallets';
export const App = () => (
<WalletProvider
wallets={[WalletType.Sui]}
>
// other components...
</WalletProvider>
);
useWallet()
returns:
- connect: (walletType: WalletType) => void - tries connect to provided wallet
- signAndSubmitTransaction: (tx: MoveCallTransaction): Promise\ - submits provided transaction
- isConnected: () => boolean
- accounts: SuiAddress[]
example:
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>
);
}
1.0.0
2 years ago