Sui Dapp Integration
(Require app ver > 12.5.0)
dApps can make requests to the wallet from their website:
// Note
const Permissions = ['viewAccount','suggestTransactions'] as const;
requestPermission(permissions: Permission[])
: prompts the user to allow connection from the dApp (neccessary to make other requests)hasPermission(Permissions)
: check permisstion of the user to allow connection from the dApp (neccessary to make other requests)getAccounts()
: gets the address of the account signed into the wallet
// Note
interface MoveCallTransaction {
packageObjectId: ObjectId;
module: string;
function: string;
typeArguments: string[];
arguments: SuiJsonValue[];
gasPayment?: ObjectId;
gasBudget: number;
}
executeMoveCall(tx: MoveCallTransaction)
: signs and broadcast the given transaction and submits to chainexecuteSerializedMoveCall(tx: Base64EncodedString)
: signs and broadcast (with Serialized) the given transaction and submits to chain
// Check connection status of wallet
const result = await window.suiWallet.requestPermissions(Permissions)
// OR
const result = await window.coin98.suiWallet.requestPermissions(Permissions)
// Check connection status of wallet
const result = await window.suiWallet.mi(Permissions)
// OR
const result = await window.coin98.suiWallet.mi(Permissions)
// Gets the address of the account signed into the wallet
const result = await window.suiWallet.getAccounts()
// OR
const result = await window.coin98.suiWallet.getAccounts()
// Sign transaction
const result = await window.suiWallet.executeMoveCall(txs)
// OR
const result = await window.coin98.suiWallet.executeMoveCall(txs)
// EX:
const serializer = new RpcTxnDataSerializer('https://gateway.devnet.sui.io')
const serializedTxs = (signer) => serializer.newMoveCall(signer, txs)
const tx = await serializedTxs(<address>)
// Sign transaction (with Serialized)
const result = await window.suiWallet.executeSerializedMoveCall(tx.toString())
// OR
const result = await window.coin98.suiWallet.executeSerializedMoveCall(tx.toString())