# Sui(更新中...)

当前是 devnet 版本, BitKeep 会跟随跟随官方升级

Bitkeep 钱包仅在以下版本支持此功能

platform version description
chrome Extension >=v1.4.1 devnet
App(ios) >=v7.2.8 devnet
App(android) >=v7.2.8 devnet

# 快速接入(推荐)

  1. 如果您还没有安装 BitKeep Wallet, 请下载download (opens new window)

  2. 获取一些测试网代币:faucet Sui (opens new window)

  3. 可参考官网推荐标准的方式接入(多钱包)

    TIP

    由于还在 devnet 网络, 我们暂时提供了基于 sui 官方提供的Sui Wallet Adapter (opens new window), 提供了react Demo (opens new window), 它是基于wallet-standard (opens new window)的标准.

# 其他方式接入

Note

以下方式仅支持BitKeep钱包

# 检测 suiWallet 提供者

如果 BitKeep 钱包没有安装,你可以提示用户先安装 BitKeep 钱包,并提供以下安装说明。例如,见下文:

function getSuiWallet() {
  const provider = window.bitkeep && window.bitkeep.suiWallet;
  if (!provider) {
    window.open('https://bitkeep.com/en/download?type=2');
    throw 'Please go to  https://bitkeep.com/en/download?type=2  to download!!';
  }
  return provider;
}
1
2
3
4
5
6
7
8

# hasPermissions

用户是否已经批准授权

  const permissions = ['viewAccount', 'suggestTransactions']
  bitkeep.suiWallet.hasPermissions(permissions): Promise<boolean>;;
1
2

# requestPermissions

我们可以通过调用bitkeep.suiWallet.requestPermissions来授权 BitKeep 钱包。

提示

在用户第一次批准授权后,网络应用程序的域名将被记住,用于未来的会话。

const permissions = ['viewAccount', 'suggestTransactions']
bitkeep.suiWallet.requestPermissions(permissions): Promise<boolean>;;
1
2
3
const wallet = getSuiWallet();
try {
  const response = await wallet.requestPermissions();
  const account = await wallet.getAccounts();
  const [address] = account;
} catch (error) {
  // { code: 4001, message: "User rejected the request."}
}
1
2
3
4
5
6
7
8
9

# getAccounts

获取用户地址

bitkeep.suiWallet.getAccounts(): Promise<Array>;
1

# 发送交易签名

# signAndExecuteTransaction

bitkeep.suiWallet.signAndExecuteTransaction(): Promise<txhash>;
bitkeep.suiWallet.signAndExecuteTransaction(
    {
    "type": "move-call",
    "data": {
      "packageObjectId": "0x2",
      "module": "devnet_nft",
      "function": "mint",
      "typeArguments": [],
      "arguments": [
        "Example NFT",
        "An example NFT created by demo Dapp",
        "ipfs://bafkreibngqhl3gaa7daob4i2vccziay2jjlp435cf66vhono7nrvww53ty"
      ],
      "gasBudget": 10000
    }
  };
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20