### Install @kynesyslabs/demosdk with Bun, npm, or yarn Source: https://kynesyslabs.github.io/demosdk-api-ref/index Installs the Demos SDK using different package managers. Supports Bun, npm, and yarn. ```bash bun install @kynesyslabs/demosdk ``` ```bash npm install @kynesyslabs/demosdk ``` ```bash yarn add @kynesyslabs/demosdk ``` -------------------------------- ### Web2Proxy Method: startProxy Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/web2 Starts the proxy with the specified parameters. ```APIDOC ## Method startProxy ### Description Start the proxy. ### Method POST ### Endpoint /startProxy ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **params** (IStartProxyParams) - Required - The parameters for starting the proxy. ### Request Example ```json { "params": { "setting1": "value1", "setting2": "value2" } } ``` ### Response #### Success Response (200) - **result** (IWeb2Result) - The result of the proxy operation. #### Response Example ```json { "result": { "status": "success", "data": {} } } ``` ``` -------------------------------- ### Initialize Demos SDK and connect wallet Source: https://kynesyslabs.github.io/demosdk-api-ref/index Guides through initializing the Demos SDK, connecting to a network, managing wallets with mnemonics, and retrieving the wallet address. ```javascript import { Demos } from "@kynesyslabs/demosdk/websdk" // 1. Initialize Demos SDK (no parameters) const demos = new Demos() // 2. Connect to the network const rpc = "https://demosnode.discus.sh" await demos.connect(rpc) // 3. Generate a new mnemonic or use existing one const mnemonic = demos.newMnemonic() // Generates 12-word mnemonic // const mnemonic = "your existing mnemonic phrase..." // Or use existing // 4. Connect your wallet await demos.connectWallet(mnemonic) // 5. Get your wallet address const address = demos.getAddress() console.log("Wallet address:", address) ``` -------------------------------- ### Native Transaction Example Source: https://kynesyslabs.github.io/demosdk-api-ref/index Shows how to perform a native transaction, such as sending DEM tokens, by transferring, confirming, and broadcasting the transaction. ```APIDOC ## Native Transaction Example ### Description Executes a native token transfer by preparing the transaction, confirming it, and broadcasting it to the network. ### Method `demos.transfer(to, amount)`, `demos.confirm(tx)`, `demos.broadcast(validityData)` ### Endpoint N/A (SDK methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript // Send native DEM tokens const tx = await demos.transfer( "0x6690580a02d2da2fefa86e414e92a1146ad5357fd71d594cc561776576857ac5", 100 // amount in DEM ) // Confirm and broadcast transaction const validityData = await demos.confirm(tx) const result = await demos.broadcast(validityData) ``` ### Response #### Success Response (200) - `result` (any) - The result of the broadcasted transaction. #### Response Example ```json { "result": "Transaction successful" } ``` ``` -------------------------------- ### Start Web2 Proxy Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/web2 Starts the web2 proxy with provided parameters. Returns a Promise resolving to an IWeb2Result object. ```typescript startProxy(params: IStartProxyParams): Promise ``` -------------------------------- ### Cross-chain Transaction Example Source: https://kynesyslabs.github.io/demosdk-api-ref/index Illustrates how to execute a cross-chain transaction by preparing payloads for different chains and creating a unified Demos transaction. ```APIDOC ## Cross-chain Transaction Example ### Description Facilitates a cross-chain transaction by preparing individual chain payloads (e.g., EVM), creating an XMScript, converting it to a Demos transaction, and then confirming and broadcasting. ### Method `EVM.create(rpc)`, `evm.connectWallet(privateKey)`, `evm.preparePay(recipient, amount)`, `prepareXMScript(scriptData)`, `prepareXMPayload(xmscript, demos)` ### Endpoint N/A (SDK methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript import { prepareXMPayload, prepareXMScript } from "@kynesyslabs/demosdk/websdk" import { EVM } from "@kynesyslabs/demosdk/xm-websdk" // 1. Create cross-chain payload (e.g., Ethereum Sepolia) const evm = await EVM.create("https://rpc.ankr.com/eth_sepolia") await evm.connectWallet("your_ethereum_private_key") const evmTx = await evm.preparePay( "0xRecipientAddress", "0.001" // 0.001 ETH ) // 2. Create XMScript const xmscript = prepareXMScript({ chain: "eth", subchain: "sepolia", signedPayloads: [evmTx], type: "pay" }) // 3. Convert to Demos transaction const tx = await prepareXMPayload(xmscript, demos) // 4. Confirm and broadcast const validityData = await demos.confirm(tx) const result = await demos.broadcast(validityData) ``` ### Response #### Success Response (200) - `result` (any) - The result of the broadcasted cross-chain transaction. #### Response Example ```json { "result": "Cross-chain transaction successful" } ``` ``` -------------------------------- ### Creating L2PS Instances with Different Keys (JavaScript) Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/l2ps Provides examples of creating new L2PS instances. One instance is created with automatically generated random keys, while another is created using a specific private key and initialization vector (IV). ```javascript // Create with random keys const l2ps1 = await L2PS.create(); // Create with specific keys const myPrivateKey = "mySecurePrivateKey"; const myIV = "myInitializationVector"; const l2ps2 = await L2PS.create(myPrivateKey, myIV); ``` -------------------------------- ### Create Solana Instance (Static) Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmcore A static factory method to create a specific instance of the SOLANA core object, associating it with a given RPC URL. This is a convenient way to get a pre-configured Solana client. ```typescript static createInstance(rpc_url: string): xmcore.SOLANA; ``` -------------------------------- ### Get Wallet Balance - @kynesyslabs/demosdk Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmwebsdk Fetches the balance of a given XRP address. It can optionally query for multiple balances. Returns the balance as a promise resolving to a string. ```typescript getBalance(address: string, multi?: boolean): Promise ``` -------------------------------- ### Build Demos SDK from source Source: https://kynesyslabs.github.io/demosdk-api-ref/index Instructions for building the SDK from source code using Bun, npm, or yarn. ```bash # Install dependencies first bun install # or npm install, or yarn install # Then build bun run build # or npm run build, or yarn build ``` -------------------------------- ### Initialization and Wallet Connection Source: https://kynesyslabs.github.io/demosdk-api-ref/index Demonstrates how to initialize the Demos SDK, connect to a network, and establish a wallet connection using a mnemonic phrase. ```APIDOC ## Initialize and Connect Wallet ### Description Initializes the Demos SDK, connects to a specified RPC endpoint, generates or uses an existing mnemonic, and connects the wallet. ### Method `new Demos()` and `demos.connect(rpc)`, `demos.connectWallet(mnemonic)` ### Endpoint N/A (SDK methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript import { Demos } from "@kynesyslabs/demosdk/websdk" // 1. Initialize Demos SDK (no parameters) const demos = new Demos() // 2. Connect to the network const rpc = "https://demosnode.discus.sh" await demos.connect(rpc) // 3. Generate a new mnemonic or use existing one const mnemonic = demos.newMnemonic() // Generates 12-word mnemonic // const mnemonic = "your existing mnemonic phrase..." // Or use existing // 4. Connect your wallet await demos.connectWallet(mnemonic) // 5. Get your wallet address const address = demos.getAddress() console.log("Wallet address:", address) ``` ### Response #### Success Response (200) - `address` (string) - The connected wallet's public address. #### Response Example ```json { "address": "0x123..." } ``` ``` -------------------------------- ### createInstance Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmcore Creates a static instance of the SOLANA core. ```APIDOC ## Static createInstance ### Description Creates a static instance of the xmcore.SOLANA core. ### Method POST ### Endpoint /createInstance ### Parameters #### Request Body - **rpc_url** (string) - Required - The RPC URL to initialize the instance with. ### Response #### Success Response (200) - **xmcore.SOLANA** - A new instance of xmcore.SOLANA. ``` -------------------------------- ### Get Wallet Balance Source: https://kynesyslabs.github.io/demosdk-api-ref/interfaces/xmcore Fetches the balance of a specified wallet address. ```APIDOC ## GET /getBalance ### Description Gets the balance of a wallet. ### Method GET ### Endpoint /getBalance ### Parameters #### Query Parameters - **address** (string) - Required - The wallet address. - **options** (object) - Optional - Additional options. ### Request Example `/getBalance?address=0xabc...` ### Response #### Success Response (200) - **string**: The balance of the wallet as a string. #### Response Example ```json "1000000000000000000" ``` ``` -------------------------------- ### Get Wallet Address Source: https://kynesyslabs.github.io/demosdk-api-ref/interfaces/xmcore Retrieves the address of the currently connected wallet. ```APIDOC ## GET /getAddress ### Description Returns the address of the connected wallet. ### Method GET ### Endpoint /getAddress ### Parameters ### Request Body None ### Request Example None ### Response #### Success Response (200) - **string**: The wallet address. #### Response Example ```json "0xabc..." ``` ``` -------------------------------- ### Use local Demos SDK in a project Source: https://kynesyslabs.github.io/demosdk-api-ref/index Explains how to add the SDK to a local project after building it from source. ```bash # Build the SDK bun run build # or yarn build, or npm run build # In your project bun add file:../path/to/sdks # or yarn/npm add file:../path/to/sdks ``` -------------------------------- ### Get User Points API Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/abstraction Retrieves the points associated with an identity. ```APIDOC ## GET /getUserPoints ### Description Retrieves the points associated with an identity. Defaults to the connected wallet's address. ### Method GET ### Endpoint /getUserPoints ### Parameters #### Query Parameters - **address** (string) - Optional - The address to get points for. ### Request Example ```json { "demos": "Demos instance", "address": "0x123..." } ``` ### Response #### Success Response (200) - **pointsData** (RPCResponseWithValidityData) - The points data for the identity. #### Response Example ```json { "result": { "points": 100, "isValid": true } } ``` ``` -------------------------------- ### Get Identities API Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/abstraction Retrieves identities associated with a given address. ```APIDOC ## GET /getIdentities ### Description Retrieves identities associated with a given address. ### Method GET ### Endpoint /getIdentities ### Parameters #### Query Parameters - **address** (string) - Optional - The address to get identities for. ### Request Example ```json { "demos": "Demos instance", "address": "0x123..." } ``` ### Response #### Success Response (200) - **identities** (RPCResponse) - The identities associated with the address. #### Response Example ```json { "result": { "identities": [ { "type": "web2", "username": "user123" } ] } } ``` ``` -------------------------------- ### POST /create Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmwebsdk Creates a new instance of this SDK connected to the RPC provider. ```APIDOC ## POST /create ### Description Creates a new instance of this SDK connected to the RPC provider. ### Method POST ### Endpoint /create ### Parameters #### Request Body - **rpc_url** (string) - Optional - The RPC URL to connect to ### Response #### Success Response (200) - **object** - The SDK instance connected to the RPC provider ``` -------------------------------- ### Get All L2PS Instances Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/l2ps Retrieves all currently active L2PS instances managed by the SDK. ```APIDOC ## GET /l2ps/instances ### Description Retrieves all currently active L2PS instances. ### Method GET ### Endpoint /l2ps/instances ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **instances** (L2PS[]) - An array of all L2PS instances. #### Response Example ```json { "instances": [ { "id": "instance-1", "status": "active" }, { "id": "instance-2", "status": "inactive" } ] } ``` ``` -------------------------------- ### create Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmcore Creates a new instance of the SDK, optionally connecting to a specified RPC URL. ```APIDOC ## Static create ### Description Creates a new instance of this SDK, optionally connecting to an RPC provider. ### Method POST ### Endpoint /create ### Type Parameters - **T** - Extends DefaultChain ### Parameters #### Request Body - **rpc_url** (string) - Optional - The RPC URL to connect to. Defaults to "". ### Response #### Success Response (200) - **Promise** - The SDK instance connected to the RPC provider. ``` -------------------------------- ### Import core modules from Demos SDK Source: https://kynesyslabs.github.io/demosdk-api-ref/index Demonstrates how to import key modules like Demos, prepareXMPayload, and DemosWork from the SDK. ```javascript import { Demos } from "@kynesyslabs/demosdk/websdk" import { prepareXMPayload } from "@kynesyslabs/demosdk/xm-websdk" import { DemosWork } from "@kynesyslabs/demosdk/demoswork" ``` -------------------------------- ### UnifiedCrypto - Get ID Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/encryption Retrieves a unique identifier for the current UnifiedCrypto instance. ```APIDOC ## GET /unifiedcrypto/getId ### Description Retrieves a unique identifier associated with the current instance of the UnifiedCrypto class. This ID can be used for managing multiple instances or tracking cryptographic operations. ### Method GET ### Endpoint /unifiedcrypto/getId ### Parameters None ### Response #### Success Response (200) - **id** (string) - The unique identifier for the UnifiedCrypto instance. #### Response Example ```json { "id": "crypto-instance-12345" } ``` ``` -------------------------------- ### Get Wallet Address Source: https://kynesyslabs.github.io/demosdk-api-ref/interfaces/xmcore Retrieves the blockchain address of the currently connected wallet. ```typescript getAddress(): string ``` -------------------------------- ### Get Xm Identities API Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/abstraction Retrieves the crosschain identities associated with an address. ```APIDOC ## GET /getXmIdentities ### Description Retrieves the crosschain identities associated with an address. ### Method GET ### Endpoint /getXmIdentities ### Parameters #### Query Parameters - **address** (string) - Optional - The address to get identities for. ### Request Example ```json { "demos": "Demos instance", "address": "0x123..." } ``` ### Response #### Success Response (200) - **identities** (RPCResponse) - The identities associated with the address. #### Response Example ```json { "result": { "identities": [ { "type": "xm", "username": "xm_user_456" } ] } } ``` ``` -------------------------------- ### Constructor Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/encryption.PQC Initializes a new instance of the Enigma class. ```APIDOC ## Constructor ### constructor * new Enigma(): Enigma * #### Returns Enigma ``` -------------------------------- ### SOLANA Class Constructor Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmcore Initializes a new SOLANA instance with the provided RPC URL. ```APIDOC ## new SOLANA(rpc_url) ### Description Initializes a new SOLANA instance with the provided RPC URL. ### Method CONSTRUCTOR ### Parameters #### Path Parameters - **rpc_url** (string) - Required - The URL of the Solana RPC provider. ### Returns - **xmcore.SOLANA** - The initialized SOLANA instance. ``` -------------------------------- ### Get Web2 Identities API Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/abstraction Retrieves the Web2 identities associated with an address. ```APIDOC ## GET /getWeb2Identities ### Description Retrieves the Web2 identities associated with an address. ### Method GET ### Endpoint /getWeb2Identities ### Parameters #### Query Parameters - **address** (string) - Optional - The address to get identities for. ### Request Example ```json { "demos": "Demos instance", "address": "0x123..." } ``` ### Response #### Success Response (200) - **identities** (RPCResponse) - The identities associated with the address. #### Response Example ```json { "result": { "identities": [ { "type": "web2", "username": "user123" } ] } } ``` ``` -------------------------------- ### Get Referral Info API Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/abstraction Retrieves referral information for a given address. ```APIDOC ## GET /getReferralInfo ### Description Retrieves referral information for an address. Defaults to the connected wallet's address. ### Method GET ### Endpoint /getReferralInfo ### Parameters #### Query Parameters - **address** (string) - Optional - The address to get referral info for. ### Request Example ```json { "demos": "Demos instance", "address": "0x123..." } ``` ### Response #### Success Response (200) - **referralInfo** (RPCResponse) - The referral information associated with the address. #### Response Example ```json { "result": { "referrer": "0xabc...", "referralCount": 5 } } ``` ``` -------------------------------- ### XRPL Class Constructor Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmwebsdk Initializes a new instance of the XRPL class with the provided RPC URL. ```APIDOC ## Constructors ### constructor * new XRPL(rpc_url): xmwebsdk.XRPL * #### Parameters * rpc_url: string #### Returns xmwebsdk.XRPL ``` -------------------------------- ### Web2Proxy Constructor Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/web2 Initializes a new instance of the Web2Proxy class. ```APIDOC ## Constructor Web2Proxy ### Description Initializes a new instance of the Web2Proxy class. ### Method constructor ### Parameters #### Path Parameters - **sessionId** (string) - Required - The session ID. - **demos** (Demos) - Required - The demos object. #### Query Parameters N/A #### Request Body N/A ### Request Example ```json { "sessionId": "your_session_id", "demos": {} } ``` ### Response #### Success Response (200) N/A (Constructor does not return a value) #### Response Example N/A ``` -------------------------------- ### UnifiedCrypto - Get Identity Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/encryption Retrieves the cryptographic identity (public and private keys) for a specified algorithm. ```APIDOC ## GET /unifiedcrypto/getIdentity ### Description Retrieves the cryptographic identity, including the public and private keys, for a specified algorithm. This allows access to the keys necessary for signing, verification, encryption, and decryption. ### Method GET ### Endpoint /unifiedcrypto/getIdentity ### Parameters #### Query Parameters - **algorithm** (string) - Required - The algorithm for which to retrieve the identity. Accepts 'falcon', 'ml-dsa', 'ed25519', 'ml-kem-aes', or 'rsa'. ### Response #### Success Response (200) - **identity** (object) - An object containing the cryptographic identity details: - **publicKey** (PublicKey | NativeBuffer | Uint8Array) - The public key. - **privateKey** (NativeBuffer | Uint8Array | PrivateKey) - The private key. - **genKey** (Uint8Array) - Optional - Additional key material, if applicable (e.g., for PQC schemes). #### Response Example ```json { "identity": { "publicKey": "...", "privateKey": "..." } } ``` ``` -------------------------------- ### getInstance Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmcore Retrieves the singleton instance of the SDK. ```APIDOC ## Static getInstance ### Description Retrieves the singleton instance of the SDK. ### Method GET ### Endpoint /getInstance ### Response #### Success Response (200) - **boolean | xmcore.SOLANA** - The SDK instance if it exists, otherwise false. ``` -------------------------------- ### UnifiedCrypto: Get Instance ID Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/encryption Retrieves the unique identifier for the current instance of the UnifiedCrypto class. ```typescript getId(): string ``` -------------------------------- ### MessagingPeer Constructor Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/instantMessaging Initializes a new instance of the MessagingPeer class. ```APIDOC ## new MessagingPeer(config) ### Description Initializes a new instance of the MessagingPeer class. ### Parameters * **config** (MessagingPeerConfig) - The configuration object for the MessagingPeer. ### Returns MessagingPeer - A new instance of the MessagingPeer class. ``` -------------------------------- ### Get All L2PS Instances Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/l2ps Retrieves all currently active L2PS instances. This method returns an array of L2PS objects. ```typescript getInstances(): L2PS[] ``` -------------------------------- ### Get All Instance IDs (JavaScript) Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/encryption Retrieves an array of all available instance IDs. Returns a string array. ```javascript getInstanceIds(): string[] ``` -------------------------------- ### Get Session ID Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/web2 Retrieves the current session ID associated with the Web2Proxy instance. Returns a string. ```typescript get sessionId(): string ``` -------------------------------- ### SOLANA Methods Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmcore Provides detailed documentation for all methods available on the SOLANA class. ```APIDOC ## SOLANA Methods ### connect #### Description Connects to the RPC provider. #### Method GET #### Endpoint `/connect` #### Returns - **Promise** - A boolean indicating if the connection was successful. ### connectWallet #### Description Connects to a wallet using a private key. #### Method POST #### Endpoint `/connectWallet` #### Parameters ##### Request Body - **privateKey** (string) - Required - The private key of the wallet. #### Returns - **Promise** - The wallet object. ### createWallet #### Description Creates a new Solana wallet. #### Method POST #### Endpoint `/createWallet` #### Returns - **Promise<{ address: string; keypair: Keypair; secretKey: string; }>** - An object containing the wallet's address, keypair, and secret key. ### disconnect #### Description Disconnects from the RPC provider and the wallet. #### Method POST #### Endpoint `/disconnect` #### Returns - **Promise** - A boolean indicating if the disconnection was successful. ### fetchAccount #### Description Fetches the deserialized account data from the network. #### Method GET #### Endpoint `/fetchAccount` #### Parameters ##### Query Parameters - **address** (Address) - Required - The program address. - **options** (SolanaReadAccountDataOptions) - Optional - Options for fetching account data. #### Returns - **Promise<DecodeStruct<IdlTypeDefTyStruct, DecodedHelper<IdlTypeDef[], EmptyDefined>>>** - The deserialized account data. ### getAddress #### Description Returns the address of the connected wallet. #### Method GET #### Endpoint `/getAddress` #### Returns - **string** - The wallet address. ### getBalance #### Description Gets the balance of a wallet. #### Method GET #### Endpoint `/getBalance` #### Parameters ##### Query Parameters - **address** (string) - Required - The wallet address. #### Returns - **Promise<string>** - The balance of the wallet as a string. ### getEmptyTransaction #### Description Creates a skeleton transaction. #### Method GET #### Endpoint `/getEmptyTransaction` #### Returns - **VersionedTransaction** - A skeleton VersionedTransaction object. ### getProgramIdl #### Description Fetches the IDL (Interface Description Language) from the network for a given program ID. #### Method GET #### Endpoint `/getProgramIdl` #### Parameters ##### Query Parameters - **programId** (Address) - Required - The address of the program. #### Returns - **Promise<Idl>** - The IDL of the program. ### preparePay #### Description Creates a signed transaction to transfer the default chain currency (e.g., SOL). #### Method POST #### Endpoint `/preparePay` #### Parameters ##### Request Body - **receiver** (string) - Required - The receiver's address. - **amount** (string) - Required - The amount to transfer. - **options** (SignTxOptions) - Optional - Additional options for signing the transaction. #### Returns - **Promise<Uint8Array>** - The signed transaction as a Uint8Array. ### preparePays #### Description Creates a list of signed transactions to transfer the default chain currency. #### Method POST #### Endpoint `/preparePays` #### Parameters ##### Request Body - **payments** (IPayOptions[]) - Required - A list of payment objects, each specifying a receiver and amount. - **options** (SignTxOptions) - Optional - Additional options for signing the transactions. #### Returns - **Promise<Uint8Array[]>** - An ordered list of signed transactions. ### prepareTransfer #### Description Creates a signed transaction to transfer the default chain currency. This is an alias for `preparePays` that returns a single transaction. #### Method POST #### Endpoint `/prepareTransfer` #### Parameters ##### Request Body - **receiver** (string) - Required - The receiver's address. - **amount** (string) - Required - The amount to transfer. - **options** (Options) - Optional - Additional options for signing the transaction. #### Returns - **Promise<Awaited<ReturnType<T["preparePays"]>>[number]>** - The signed transaction. ### prepareTransfers #### Description Creates a list of signed transactions to transfer the default chain currency. This is an alias for `preparePays`. #### Method POST #### Endpoint `/prepareTransfers` #### Parameters ##### Request Body - **payments** (IPayOptions[]) - Required - A list of payment objects, each specifying a receiver and amount. - **options** (Options) - Optional - Additional options for signing the transactions. #### Returns - **Promise<Awaited<ReturnType<T["preparePays"]>>>** - An ordered list of signed transactions. ``` -------------------------------- ### create Instance Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmlocalsdk Creates a new instance of the SDK, optionally connecting to a specified RPC URL. ```APIDOC ## POST /create ### Description Creates a new instance of the SDK and connects to the RPC provider. ### Method POST ### Endpoint /create ### Parameters #### Query Parameters - **rpc_url** (string) - Optional - The RPC URL to connect to. Defaults to an empty string if not provided. ### Type Parameters - **T** (extends DefaultChain) - The type of the SDK instance to create. ### Response #### Success Response (200) - **sdkInstance** (T) - The newly created and connected SDK instance. ### Request Example ``` POST /create?rpc_url=http://example.com/rpc ``` ### Response Example ```json { "sdkInstance": { ... } // SDK instance of type T } ``` ``` -------------------------------- ### Send native DEM tokens transaction Source: https://kynesyslabs.github.io/demosdk-api-ref/index Provides an example of sending native DEM tokens, including confirming and broadcasting the transaction. ```javascript // Send native DEM tokens const tx = await demos.transfer( "0x6690580a02d2da2fefa86e414e92a1146ad5357fd71d594cc561776576857ac5", 100 // amount in DEM ) // Confirm and broadcast transaction const validityData = await demos.confirm(tx) const result = await demos.broadcast(validityData) ``` -------------------------------- ### Prepare Multiple XRP Payments - @kynesyslabs/demosdk Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmwebsdk Creates a list of signed transactions for transferring the default chain currency. Accepts an array of payment options and returns a promise resolving to an array of signed transactions. ```typescript preparePays(payments: IPayOptions[]): Promise<{}[]> ``` -------------------------------- ### Get Connected Wallet Address - @kynesyslabs/demosdk Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmwebsdk Retrieves the XRP address of the currently connected wallet. This is a synchronous method. ```typescript getAddress(): string ``` -------------------------------- ### Publish Demos SDK to NPM Source: https://kynesyslabs.github.io/demosdk-api-ref/index Automate the publishing process of the Demos SDK to NPM. This involves incrementing the version in package.json, committing with a 'release' message, and pushing to GitHub. ```shell git commit -m "release v2.3.25" git push ``` -------------------------------- ### Get Connected Wallet Address (TypeScript) Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmcore Returns the public address of the currently connected Solana wallet. This is a synchronous method. ```typescript getAddress(): string ``` -------------------------------- ### XRPL Constructor - @kynesyslabs/demosdk Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmwebsdk Initializes a new XRPL instance with a given RPC URL. This constructor is part of the @kynesyslabs/demosdk and is used to establish a connection to an XRP Ledger provider. ```typescript new XRPL(rpc_url: string): xmwebsdk.XRPL ``` -------------------------------- ### preparePays Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmwebsdk Prepares multiple signed transactions for XRP payments based on a list of payment options. ```APIDOC ## preparePays * preparePays(payments): Promise<{}[]> * Creates a list of signed transactions to transfer default chain currency #### Parameters * payments: IPayOptions[] A list of transfers to prepare #### Returns Promise<{}[]> An ordered list of signed transactions ``` -------------------------------- ### Get Wallet Balance Source: https://kynesyslabs.github.io/demosdk-api-ref/interfaces/xmcore Fetches the balance of a specified wallet address. It may accept optional parameters for specific query options. ```typescript getBalance(address: string, options?: {}): Promise ``` -------------------------------- ### Get Wallet Balance (TypeScript) Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmcore Fetches the balance of a specified Solana wallet address. This asynchronous method returns the balance as a string. ```typescript getBalance(address: string): Promise ``` -------------------------------- ### Prepare Multiple Payments Source: https://kynesyslabs.github.io/demosdk-api-ref/interfaces/xmcore Creates a list of signed transactions for multiple currency transfers. ```APIDOC ## POST /preparePays ### Description Creates a list of signed transactions to transfer default chain currency. ### Method POST ### Endpoint /preparePays ### Parameters #### Request Body - **payments** (IPayOptions[]) - Required - A list of transfers to prepare. - **options** (object) - Required - Options. ### Request Example ```json { "payments": [ { "receiver": "0xdef...", "amount": "1000000000000000000" } ], "options": {} } ``` ### Response #### Success Response (200) - **any[]**: An ordered list of signed transactions. #### Response Example ```json [ { "hash": "0xabc..." } ] ``` ``` -------------------------------- ### Get Crypto Instance (JavaScript) Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/encryption Retrieves a crypto instance, optionally specifying an instance ID and master seed. Returns a UnifiedCrypto object. ```javascript getInstance(instanceId?, masterSeed?): UnifiedCrypto ``` -------------------------------- ### Create SDK Instance (Static) Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmcore Statically creates a new instance of the SDK, optionally connecting to a specified RPC URL. This generic method allows for creating instances of different chain types that extend DefaultChain. It returns a Promise resolving to the created SDK instance. ```typescript static create(this: new (rpc_url: string) => T, rpc_url?: string): Promise; ``` -------------------------------- ### MessagingPeer Methods Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/instantMessaging Reference for all available methods in the MessagingPeer class. ```APIDOC ## awaitResponse(messageType, filterFn?, timeout?) ### Description Awaits a response for a specific message type. ### Method `awaitResponse` ### Type Parameters * **T** = any - The expected type of the response payload. ### Parameters * **messageType** (string) - The type of message to wait for. Possible values: "message", "discover", "error", "register", "peer_disconnected", "request_public_key", "public_key_response", "server_question", "peer_response", "debug_question". * **filterFn** (function, optional) - An optional function to filter messages by additional criteria. It takes a `Message` object and returns a boolean. * **timeout** (number, optional) - The timeout in milliseconds for waiting for a response. Defaults to 10000. ### Returns Promise - A promise that resolves with the message payload or rejects with an error. ``` ```APIDOC ## connect() ### Description Connects to the signaling server and registers the peer. ### Method `connect` ### Returns Promise - A promise that resolves when connected and registered. ``` ```APIDOC ## disconnect() ### Description Closes the connection to the signaling server. ### Method `disconnect` ### Returns void ``` ```APIDOC ## discoverPeers() ### Description Discovers all connected peers. ### Method `discoverPeers` ### Returns Promise - A promise that resolves with an array of peer IDs. ``` ```APIDOC ## onConnectionStateChange(handler) ### Description Adds a handler for connection state changes. ### Method `onConnectionStateChange` ### Parameters * **handler** (ConnectionStateHandler) - The function to call when the connection state changes. ### Returns void ``` ```APIDOC ## onError(handler) ### Description Adds a handler for errors. ### Method `onError` ### Parameters * **handler** (ErrorHandler) - The function to call when an error occurs. ### Returns void ``` ```APIDOC ## onMessage(handler) ### Description Adds a handler for incoming messages. ### Method `onMessage` ### Parameters * **handler** (MessageHandler) - The function to call when a message is received. ### Returns void ``` ```APIDOC ## onPeerDisconnected(handler) ### Description Adds a handler for peer disconnection events. ### Method `onPeerDisconnected` ### Parameters * **handler** (PeerDisconnectedHandler) - The function to call when a peer disconnects. ### Returns void ``` ```APIDOC ## onServerQuestion(handler) ### Description Registers a handler for server questions. ### Method `onServerQuestion` ### Parameters * **handler** (function) - The function to call when a server question is received. It accepts `question` (any) and `questionId` (string) as arguments. ### Returns void ``` ```APIDOC ## register() ### Description Registers the peer with the signaling server. ### Method `register` ### Returns void ``` ```APIDOC ## registerAndWait() ### Description Registers the peer with the signaling server and waits for confirmation. ### Method `registerAndWait` ### Returns Promise - A promise that resolves when registration is confirmed. ``` ```APIDOC ## removeConnectionStateHandler(handler) ### Description Removes a connection state change handler. ### Method `removeConnectionStateHandler` ### Parameters * **handler** (ConnectionStateHandler) - The handler to remove. ### Returns void ``` ```APIDOC ## removeErrorHandler(handler) ### Description Removes an error handler. ### Method `removeErrorHandler` ### Parameters * **handler** (ErrorHandler) - The handler to remove. ### Returns void ``` ```APIDOC ## removeMessageHandler(handler) ### Description Removes a message handler. ### Method `removeMessageHandler` ### Parameters * **handler** (MessageHandler) - The handler to remove. ### Returns void ``` ```APIDOC ## removePeerDisconnectedHandler(handler) ### Description Removes a peer disconnected handler. ### Method `removePeerDisconnectedHandler` ### Parameters * **handler** (PeerDisconnectedHandler) - The handler to remove. ### Returns void ``` ```APIDOC ## requestPublicKey(peerId) ### Description Requests a peer's public key. ### Method `requestPublicKey` ### Parameters * **peerId** (string) - The ID of the peer whose public key to request. ### Returns Promise> - A promise that resolves with the peer's public key. ``` ```APIDOC ## respondToServer(questionId, response) ### Description Responds to a server question. ### Method `respondToServer` ### Parameters * **questionId** (string) - The ID of the question to respond to. * **response** (any) - The response to the server question. ### Returns void ``` -------------------------------- ### Create Empty XRP Transaction - @kynesyslabs/demosdk Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmwebsdk Generates a skeleton for a payment transaction on the XRP Ledger. This can be used as a starting point for creating more complex transactions. ```typescript getEmptyTransaction(): Promise<{ Account: string; Amount: string; Destination: string; Sequence: number; TransactionType: "Payment"; }> ``` -------------------------------- ### Get Solana Instance (Static) Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/xmcore Retrieves the singleton instance of the Solana core object if it has already been created. Returns the instance or false if no instance exists. ```typescript static getInstance(): boolean | xmcore.SOLANA; ``` -------------------------------- ### Prepare Multiple Transfers Source: https://kynesyslabs.github.io/demosdk-api-ref/interfaces/xmcore Creates a list of signed transactions for multiple currency transfers. ```APIDOC ## POST /prepareTransfers ### Description Creates a list of signed transactions to transfer default chain currency. ### Method POST ### Endpoint /prepareTransfers ### Parameters #### Request Body - **payments** (IPayOptions[]) - Required - A list of transfers to prepare. - **options** (Options) - Optional - Options. ### Request Example ```json { "payments": [ { "receiver": "0xdef...", "amount": "1000000000000000000" } ], "options": {} } ``` ### Response #### Success Response (200) - **any[]**: An ordered list of signed transactions. #### Response Example ```json [ { "hash": "0xabc..." } ] ``` ``` -------------------------------- ### UnifiedCrypto: Get Identity Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/encryption Retrieves the cryptographic identity (key pair) for a given algorithm. It returns a Promise that resolves with an object containing the private and public keys. ```typescript getIdentity(algorithm: "falcon" | "ml-dsa" | "ed25519" | "ml-kem-aes" | "rsa"): Promise<{ genKey?: Uint8Array; privateKey: NativeBuffer | Uint8Array | PrivateKey; publicKey: PublicKey | NativeBuffer | Uint8Array; }> ``` -------------------------------- ### Class default - Constructor Source: https://kynesyslabs.github.io/demosdk-api-ref/classes/encryption.FHE Information on how to instantiate the default class. ```APIDOC ## Constructor for Class default ### new default() - **Description**: Initializes a new instance of the default class. - **Returns**: `encryption.FHE.default` ```