> For the complete documentation index, see [llms.txt](https://docs.blockbolt.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blockbolt.io/sui-network-sdk/wallet-sdk.md).

# ⚒️ Wallet SDK

The **BlockBolt SDK** for the **Sui Wallet App** offers a seamless, secure, and user-friendly interface for executing transactions on the Sui blockchain. Users can confirm payments directly within their Sui wallet with support for QR code scanning and payment interpretation.

The SDK ensures safe and reliable delivery of funds to the merchant wallet by handling all the logic on-chain.

***

### Open Source

Our payment infrastructure is fully open-source, reinforcing transparency and enabling community-driven security enhancements.

{% embed url="<https://www.npmjs.com/package/@blockbolt/boltpay-wallet>" %}

***

### Installation

Install the BlockBolt SDK using either `npm` or `yarn`:

```bash
npm install @blockbolt/boltpay-wallet
```

```bash
yarn add @blockbolt/boltpay-wallet
```

***

### Dependencies

BlockBolt SDK requires the `@mysten/sui` package as a peer dependency. Install it alongside:

```bash
npm install @mysten/sui
```

```bash
yarn add @mysten/sui
```

***

### Supported Coins

| Coin Name | Symbol | Decimals | Coin Type                   |
| --------- | ------ | -------- | --------------------------- |
| USD Coin  | USDC   | 6        | `0x5d4b...::coin::COIN`     |
| Tether    | USDT   | 6        | `0xc060...::coin::COIN`     |
| SCA Token | SCA    | 9        | `0x7016...::sca::SCA`       |
| Sacabum   | SCB    | 5        | `0x9a55...::scb::SCB`       |
| Buck USD  | BUCK   | 9        | `0xce7f...::buck::BUCK`     |
| Turbos    | TURBOS | 9        | `0x5d1f...::turbos::TURBOS` |
| FlowX     | FLX    | 8        | `0x6dae...::flx::FLX`       |
| NavX      | NAVX   | 9        | `0xa99b...::navx::NAVX`     |
| FUD Token | FUD    | 5        | `0x76cb...::fud::FUD`       |

***

### Usage

#### Initializing the SDK

```ts
import { BlockBolt } from '@blockbolt/boltpay-wallet';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';

const sdk = new BlockBolt();
```

***

#### Preparing the Keypair

Generate or import your keypair using the Sui SDK. For example:

```ts
const keyPair = Ed25519Keypair.fromSecretKey(Uint8Array.from([...]));
```

> 🔐 **Note:** Never hardcode secrets or mnemonics in production. Use secure key vaults or encrypted storage.

***

#### Sending a Transaction

```ts
const qrCodeData = {
  receiverAddr: "0xa2a0...e752",
  nameProduct: "Coffee",
  amount: 1000000000, // 1 SUI (9 decimals)
  coinType: "0x...::sui::SUI",
  randomId: "123456789",
  senderAddr: "0x9d65...ae1", // Optional
};

try {
  const result = await sdk.send({
    keyPair,
    ...qrCodeData,
    randomId: BigInt(qrCodeData.randomId),
  });

  console.log("Transaction result:", result.digest);

  if (result.effects?.status.status === "success") {
    console.log("✅ Transaction successful");
  } else {
    console.log("❌ Transaction failed:", result.effects?.status.error);
  }
} catch (error) {
  console.error("Transaction error:", error);
}
```

***

### API Reference

#### `BlockBolt.send(params)`

Send a transaction via the Sui network.

**Parameters**

* `keyPair` — `Ed25519Keypair` from Sui SDK
* `receiverAddr` — recipient wallet address
* `nameProduct` — name or description of the item/service
* `amount` — amount to send (in smallest unit of token)
* `coinType` — full coin type string
* `randomId` — unique BigInt to avoid duplicates
* `senderAddr` *(optional)* — if set, only this wallet can initiate the payment

**Returns**

A `Promise` resolving to the transaction result.

***

### Error Handling

Wrap all SDK interactions in a `try-catch` block:

```ts
try {
  const result = await sdk.send({ /* params */ });
} catch (error) {
  if (error instanceof TreasuryError) {
    console.error("Treasury error:", error.message, "Coin:", error.coinType);
  } else {
    console.error("Unhandled error:", error);
  }
}
```

***

### Examples

```ts
import { BlockBolt } from '@blockbolt/boltpay-wallet';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';

const sdk = new BlockBolt();
const generateRandomBigInt = () => BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER));

const sendTransaction = async () => {
  try {
    const result = await sdk.send({
      keyPair,
      receiverAddr: "0xa2a0...e752",
      nameProduct: "Coffee",
      amount: 1000000000,
      coinType: "0x...::sui::SUI",
      randomId: generateRandomBigInt(),
      senderAddr: "0x9d65...ae1",
    });

    console.log("Tx Digest:", result.digest);

    if (result.effects?.status.status === "success") {
      console.log("✅ Payment completed");
    } else {
      console.log("❌ Payment failed:", result.effects?.status.error);
    }
  } catch (error) {
    console.error("Transaction Error:", error);
  }
};

sendTransaction();
```

***

### Best Practices

* 🔒 **Security First**: Never expose private keys or mnemonics.
* ⚙️ **Key Management**: Use secure wallets and avoid client-side key generation for production apps.
* ✅ **Transaction Uniqueness**: Always use `randomId` to prevent duplicate submissions.
* 📤 **QR Usage**: Let users scan a QR that includes the transaction data (excluding private key).

> ℹ️ Payments are verified strictly via on-chain logic. No external verification or off-chain validation is supported.

***

### Support

Need help?

* 📧 Email: <support@blockbolt.io>
* 💬 Discord: [Join Support Server](https://discord.gg/Fb8CA6ny67)

***

### License

This project is licensed under the MIT License.

***
