After setting up your wallet, you can have access to the Sui provider:
// reactconst{providers}=useTomo()const{suiProvider}=providers;// pure jsconstsuiProvider=window.tomo_sui
Get Sui Address
The Sui address is from the wallet state or provider. In the React framework:
import{useTomo,getWalletState}from'@tomo-inc/tomo-web-sdk';const{walletState,providers}=useTomo()// get from wallet stateconstsuiAddress=walletState.suiAddress// or get from providerconstsuiAddress=awaitproviders.suiProvider.getAddress()
Or Pure JS:
Provider Functions
Signing a Message
The Sui provider signs messages in bytes and outputs the message and signature:
/** pure js */
import { getWalletState } from '@tomo-inc/tomo-web-sdk';
// get from wallet state
const suiAddress = getWalletState().suiAddress
// or get from provider
const suiAddress = await window.tomo_sui.getAddress()
// interface
signPersonalMessage(_input: { message: Uint8Array; }): Promise<
string |
{
bytes: string;
signature: string;
}
>;
// example
const encoder = new TextEncoder();
const message = encoder.encode("hello world sui");
const res = await provider?.signPersonalMessage({ message });