New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

diamwallet-sdk-react

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diamwallet-sdk-react

The DIAM Wallet Web SDK enables seamless integration of dApps with the DIAM Wallet App for secure, decentralized crypto transactions.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

DIAM Wallet Logo

DIAM WALLET

DIAM Wallet SDK

The DIAM Wallet SDK allows developers to seamlessly connect their dApps with both web apps (on Android and iOS mobile browsers) through the DIAM Wallet App.

Platform: iOS

Platform: Android

Platform: Web

License

npm version

Build status

code coverage

install size

npm bundle size

npm downloads

Getting Started

Installation

You can install the DIAM Wallet SDK using npm or yarn:

Install the SDK in your Application:


yarn  add  diamwallet-sdk-react


npm  install  --save  diamwallet-sdk-react

Setting Up the SDK in Your Application

Note: The SDK does not include a wrapper, so it must be initialized in every file where it is used.

React Web Implementation

Install web-vital for web(ReactJS).


npm  i  --save  web-vitals

import React from "react";

import DIAMWalletConnectionSDK from "diamwallet-sdk-react";

const diamWalletSdk = new DIAMWalletConnectionSDK({
  platform: "web",

  appCallback: window.location.origin + "/callback",

  appName: "Demo App1",

  network: "testnet",
});

SDK Methods

1. Connect Wallet

Establishes connection with DIAM Wallet and returns user's wallet address.

Returns:


{

status: boolean, // Connection status

address: string, // Wallet address if successful

data?: string // Error message if failed

}

React Web

const connectWallet = async () => {
  try {
    console.log("Connecting...");

    const result = await sdk.connectWallet();

    if (result.status === true) {
      setConnectionStatus(result.status);

      setWalletAddress(result.address);

      let balanceResponse = await sdk.getBalance();

      setBalance(balanceResponse.data.balance);
    }
  } catch (error) {
    console.error("Failed to connect wallet:", error);

    setConnectionStatus(false);

    alert(`Failed to connect: \n${error.message}`);
  }
};

2. Fetch Wallet Balance

Retrieves the current balance of the connected wallet.

Returns:


{

status: boolean,

data: {

balance: string

}

}

const fetchBalance = async () => {
  let balanceResponse = await diamWalletSdk.getBalance();

  console.log(balanceResponse);
};

3. Send Transaction

Sends a new transaction to a specified address.

Parameters:


{

amount: string, // Amount to send

toAddress: string, // Recipient address

signTransaction: false  // Must be false for sending

}

Returns:


{

status: boolean,

data: Array<object>; // Array of generic objects

}

const sendTransaction = async () => {
  let transactionData = {
    amount: "10", // sending amount

    toAddress: "GBVKH4ZK6QWETZTQFLQ3JMGXKMRVRK3ZPZ3Z4ACQXY42J6P7F5DRZYNY", // receiver address

    signTransaction: false,
  };

  try {
    const result = await diamWalletSdk.sendTransaction(transactionData);

    console.log(result);
  } catch (error) {
    console.error("Failed to send transaction:", error);
  }
};

4. Sign Transaction

Signs a transaction without broadcasting it to the network.

Parameters:


{

amount: string, // Amount to send

toAddress: string, // Recipient address

signTransaction: true  // Must be true for signing

}

Returns:


{

status: boolean,

data: {

xdr: string // Signed transaction XDR

}

}

const signTransaction = async () => {
  let transactionData = {
    amount: "10", // sending amount

    toAddress: "GBVKH4ZK6QWETZTQFLQ3JMGXKMRVRK3ZPZ3Z4ACQXY42J6P7F5DRZYNY", // receiver address

    signTransaction: true,
  };

  try {
    const result = await diamWalletSdk.sendTransaction(transactionData);

    console.log(result);
  } catch (error) {
    console.error("Failed to sign transaction:", error);
  }
};

5. Send Signed Transaction

Broadcasts a previously signed XDR transaction.

Parameters:


{

signTransaction: false,

xdr: string // Signed XDR string

}

Returns:


{

status: boolean,

data: Array<object>; // Array of generic objects

}

const sendSignedXDRTransaction = async () => {
  let transactionData = {
    signTransaction: false,

    xdr: selectedXDR,
  };

  try {
    const result = await diamWalletSdk.sendTransaction(transactionData);

    console.log(result);
  } catch (error) {
    console.error("Failed to send transaction:", error);
  }
};

6. Validate Public Address

Validates if a given address is formatted correctly.

Parameters:

publicAddress: string; // Address to validate

Returns:

{
  valid: boolean;
}
const addressValidation = async () => {
  let valid = await diamWalletSdk.validatePublicAddress(
    "GBVKH4ZK6QWETZTQFLQ3JMGXKMRVRK3ZPZ3Z4ACQXY42J6P7F5DRZYNY" // receiver address
  );

  console.log(valid); // {valid: true/false}
};

7. Disconnect Wallet

Terminates the connection with the DIAM Wallet.

Returns:


{

status: boolean,

message?: string // Optional status message

}

const disconnectWallet = async () => {
  try {
    await diamWalletSdk.disconnect();
  } catch (error) {
    console.error("Failed to disconnect wallet:", error);

    alert(`Failed to disconnect: \n${error.message}`);
  }
};

Configuration Options

| Option | Type | Description | Mandatory |

|--------|------|-------------|-----------|

| diamWalletOptions.platform | string | Name of your platform | Yes |

| diamWalletOptions.appCallback | string | URL of your dApp | Yes |

| diamWalletOptions.appName | string | Name of your dApp | Yes |

| diamWalletOptions.network | string | Network name ("testnet" or "mainnet") | Yes |

Available Methods

  • connectWallet(): Connect to DIAM Wallet Application

  • getBalance(): Fetch balance for the connected wallet

  • sendTransaction({amount, toAddress, signTransaction: false}): Send transaction to specified public address

  • signTransaction({amount, toAddress, signTransaction: true}): Sign transaction for specified public address

  • sendTransaction({signTransaction: false, xdr}): Send signed XDR transaction

  • validatePublicAddress(publicAddress): Validate public address

  • disconnect(): Terminate DIAM Wallet connection

Resources

  • GitHub Repository

  • Issues

  • Example Project

Support

For additional support, please open an issue on our GitHub repository.

License

The DIAM Wallet Mobile SDK is licensed under the MIT License.

You are free to use, modify, and distribute the SDK in your projects, subject to the conditions of the MIT License.

Conditions

  • The software is provided "as is", without any warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement.

  • In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software

Keywords

diamwallet-sdk

FAQs

Package last updated on 21 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts