1.2.6 • Published 1 year ago

dummmytest v1.2.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

BlockBolt SDK

BlockBolt SDK is a powerful and easy-to-use library for interacting with the Sui blockchain. It provides a simple interface for sending transactions and managing coins on the Sui network.

Table of Contents

Installation

Install the BlockBolt SDK using npm:

npm install blockbolt-sdk

Or using yarn:

yarn add blockbolt-sdk

Dependencies

BlockBolt SDK requires the @mysten/sui package as a peer dependency. Make sure to install it alongside the SDK:

npm install @mysten/sui

Or using yarn:

yarn add @mysten/sui

Supported Coins

BlockBolt SDK currently supports the following coins:

Coin NameSymbolDecimalsCoin Type
USD CoinUSDC60x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN
TetherUSDT60xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN
SCA TokenSCA90x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA
SacabumSCB50x9a5502414b5d51d01c8b5641db7436d789fa15a245694b24aa37c25c2a6ce001::scb::SCB
Buck USDBUCK90xce7ff77a83ea0cb6fd39bd8748e2ec89a3f41e8efdc3f4eb123e0ca37b184db2::buck::BUCK
TurbosTURBOS90x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c355171f84bb1ba4a::turbos::TURBOS
FlowXFLX80x6dae8ca14311574fdfe555524ea48558e3d1360d1607d1c7f98af867e3b7976c::flx::FLX
NavXNAVX90xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX
FUD TokenFUD50x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD

Usage

Initializing the SDK

First, import and initialize the BlockBolt SDK:

import { BlockBolt } from 'blockbolt-sdk';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';

const sdk = new BlockBolt();

Sending a Transaction

To send a transaction, use the send method:

const phrase = "your mnemonic phrase here";
const keyPair = Ed25519Keypair.deriveKeypair(phrase, "m/44'/784'/0'/0'/0'");

const generateRandomBigInt = () => BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER));
const randomId = generateRandomBigInt();

const result = await sdk.send({
    keyPair,
    receiverAddr: "0xa2a0c531c0aecf0e96f2834e846422eb49e77fb50410cb9f09c797ba902ce752",
    nameProduct: 'Coffee',
    amount: 1000000, // Amount in smallest unit (e.g., 1 FUD with 5 decimals)
    coinType: "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD",
    randomId: randomId
});

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

API Reference

BlockBolt.send(params)

Sends a transaction on the Sui network.

Parameters:

  • params.keyPair: The Ed25519Keypair derived from the mnemonic phrase
  • params.receiverAddr: The recipient's address
  • params.nameProduct: Name or description of the product/service
  • params.amount: Amount to send (in the smallest unit of the coin)
  • params.coinType: The type of coin to send (use the full coin type string)
  • params.randomId: A random BigInt for transaction uniqueness

Returns: A promise that resolves to the transaction result.

Error Handling

The SDK uses custom error types for different scenarios. Always wrap your SDK calls in a try-catch block:

try {
    const result = await sdk.send(/* ... */);
    // Handle successful transaction
} catch (error) {
    if (error instanceof MerchantFeeError) {
        console.error('Merchant fee error:', error.message, 'Coin type:', error.coinType);
    } else {
        console.error('Transaction failed:', error);
    }
}

Examples

Here's a complete example of using the BlockBolt SDK:

import { BlockBolt } from 'blockbolt-sdk';
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';

const sdk = new BlockBolt();

const phrase = "bolt volt bvo sdfldf sdfl sdf sdf sdf sdf sdf ";
const keyPair = Ed25519Keypair.deriveKeypair(phrase, "m/44'/784'/0'/0'/0'");

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

const sendTransaction = async () => {
    try {
        const result = await sdk.send({
            keyPair,
            receiverAddr: "0xa2a0c531c0aecf0e96f2834e846422eb49e77fb50410cb9f09c797ba902ce752",
            nameProduct: 'Coffee',
            amount: 1000000, // 1 FUD (5 decimal places)
            coinType: "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD",
            randomId: generateRandomBigInt()
        });
        
        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 failed:', error);
    }
};

sendTransaction();

Contributing

We welcome contributions to the BlockBolt SDK! Please see our Contributing Guide for more details.

License

This project is licensed under the MIT License.

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.9

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago