Tomo Docs
Tomo Docs
  • Overview
    • Introducing Tomo
    • Tomo's Key Management
  • Tomo SDK
    • TomoEVMKit
      • Quick Start
      • Use with Ethers.js
      • Migration from RainbowKit
      • Migration from Blocknative
      • Internal Wallet Services
      • Supported Chains
    • Tomo Web SDK
      • Quick Start
      • Solana Provider
      • EVM Provider
      • Bitcoin Provider
      • Tron Provider
      • Movement Provider
      • Sui Provider
      • Internal Wallet Services
    • Tomo Telegram SDK
      • Quick Start
      • Wallet Provider
        • EVM Provider
        • Solana Provider
        • Sui Provider (Beta)
        • TON Provider
      • Partners
    • Tomo Enterprise SDK
      • For Babylon
        • Install the SDK
        • Tomo Wallet Provider
        • Bitcoin Provider
        • Cosmos Provider
        • Multiple Connection Mode
        • Integrate Extension Wallet
          • Submit Wallet PR
          • Extend the SDK
          • Q & A
        • Integrate Mobile Wallet
  • TOMO WALLET
    • Tomo Wallets
    • Mobile Wallet
      • Tomo Keys
        • Bonding Curve Explained
        • How to: Tomo Keys
      • TomoID
        • How to: TomoID
        • How to: Connect Instagram
      • Tomo Socials
      • Tomo Android App
      • Tomo iOS App
    • Extension Wallet
      • Developer Manual
        • EVM Integration
        • Bitcoin Integration
      • Example of User Flows
        • Claiming Signet BTC
        • Staking at Testnet
      • Install Link
    • Telegram Wallet
      • Quick Start
      • Chains/Networks
      • User Manual
        • Account Security
        • Gift feature
        • FAQ
        • Transaction
        • Swap
  • ABOUT US
    • Brand Assets
    • Privacy Policy
Powered by GitBook
On this page
  • Connect with the Wallet​
  • Query Address
  • Signing Methods
  • Sign message
  • Sign transaction
  1. Tomo SDK
  2. Tomo Telegram SDK
  3. Wallet Provider

Sui Provider (Beta)

PreviousSolana ProviderNextTON Provider

Last updated 6 months ago

The Tomo Telegram SDK provides the SUI provider for getting addresses, signing, and sending transactions.

// get provider 
const sui= window.tomo_sui;

Connect with the Wallet

Before using the provider, the user needs to log in to the wallet through the modal by following the method:

// connect wallet
await sui?.connectWallet();

Query Address

You can get the address of the user by one cal

const address = sui.getAddress();

Signing Methods

In Solana providers, we provide three signing methods:

  • signMessage

  • signTransaction

  • signAndExecuteTransaction

Sign message

signMessage method will create a simple signed transaction for one message and return the signed transaction in hex.

 const response = await sui.signMessage(signMsg);

Sign transaction

// define transaction body
export const getSendSuiCoinTx = async ({
  fromAddress,
  toAddress,
  amount,
  coinType,
}: {
  fromAddress: string;
  toAddress: string;
  amount: string;
  coinType?: string;
}): Promise<{ transaction: string; bytes: Uint8Array } | null> => {
  const suiClient = getSuiClient();
  const txb = new Transaction();
  
  txb.transferObjects(
    [coinWithBalance({ balance: Number(amount), type: coinType || undefined })],
    toAddress
  );
  
  try {
    txb.setSender(fromAddress);
    const transaction = (await txb.toJSON({ client: suiClient })).toString();
    const bytes = await txb.build({ client: suiClient });
    console.log('bytes', transaction, bytes);
    return { transaction, bytes };
  } catch (e) {
    console.warn(e);
    return null;
  }
};

// create transaction body for concrete transaction
const res = await getSendSuiCoinTx({
  fromAddress: addr,
  toAddress: toAddr2,
  amount: +toValue2 * 10 ** 6 + '',
  coinType: contractAddr,
});

// create transaction
const { transaction, bytes } = res || {};

const input = {
  transactionBlock: transaction,
  chain: 'sui:mainnet',
  txBytes: bytes,
  options: {
    showEffects: true,
  },
};

// sign transaction
const signed transaction= await sui.signTransaction(input);

// or you can use sign and send transaction at the same time

const res = await sui.signAndExecuteTransaction(input);

After signing the transaction, you can send it to your client or add other signatures. In addition, you can use signAndExecuteTransaction the method to send the signed transaction directly.

signTransaction supports signing arbitrary PTB transactions if they are well formed. Please check for the general construction of transactions. We provide two examples:

​
this