Documentation Index
Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
The @dynamic-labs/sui-extension integrates your application with the Sui blockchain, providing a SuiClient and Signer to interact with the Sui network.
Installation
To install the Sui extension, run the following command:
npm install @dynamic-labs/sui-extension
Setup
Incorporate the Sui extension into your client using the extend method to add getSigner, getNetworkUrl, and getNetworkName methods:
import { createClient } from '@dynamic-labs/client'
import { SuiExtension } from '@dynamic-labs/sui-extension'
/**
* Creates and extends the client with Sui blockchain functionality.
*/
export const dynamicClient = createClient({
environmentId: 'YOUR-ENVIRONMENT-ID',
}).extend(SuiExtension())
Also please refer to the Polyfills section for information on how to set up necessary polyfills.
Usage
After setup, you can interact with the Sui blockchain. Below is an example of a component that sends SUI tokens to a specified wallet address:
import { Button } from 'react-native'
import { FC } from 'react'
import { dynamicClient } from '<path to client file>'
import { Transaction } from '@mysten/sui/transactions'
import { SuiClient } from '@mysten/sui.js/client'
interface SendSuiButtonProps {
destinationAddress: string
amount: string
}
/**
* Renders a button that sends SUI to a given address.
*/
const SendSuiButton: FC<SendSuiButtonProps> = ({ destinationAddress, amount }) => {
const send = async () => {
const wallet = dynamicClient.wallets.primary
if (!wallet) return
const networkUrl = await dynamicClient.sui.getNetworkUrl({ walletId: wallet.id })
const suiClient = new SuiClient({ url: networkUrl })
const signer = dynamicClient.sui.getSigner({ wallet })
const transferTransaction = new Transaction()
transferTransaction.setSender(wallet.address)
const [coin] = transferTransaction.splitCoins(transferTransaction.gas, [
BigInt(amount) * BigInt(1000000000) // Convert to MIST (SUI's smallest unit)
])
transferTransaction.transferObjects([coin], destinationAddress)
const { signature } = await signer.signTransaction(transferTransaction)
const txBytes = await transferTransaction.build({ client: suiClient })
const { digest } = await suiClient.executeTransactionBlock({
transactionBlock: txBytes,
signature,
})
console.log('Successful transaction digest:', digest)
}
return <Button title="Send SUI" onPress={send} />
}
Chain Support
Sui support is available for React Native applications as of v4.26.0. This enables:
- Wallet connection and management for Sui wallets
- Transaction signing and execution
- Integration with Sui dApps and protocols
- Support for embedded wallets on Sui network
Configuration
To enable Sui support in your Dynamic configuration, make sure to:
- Enable Sui chain in your Dynamic dashboard
- Configure Sui network settings as needed
- Install and configure the Sui extension as shown above
For more information about enabling chains and networks, see the enabling chains guide.