npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

digiffer-wallet-reactjs

v1.0.7

Published

DigifferWallet is a JavaScript library designed to integrate Google OAuth login for creating and managing blockchain wallets. It provides a simple interface to show a login popup, handle Google login responses, and perform various wallet-related operation

Downloads

18

Readme

DigifferWallet

DigifferWallet is a JavaScript library designed to integrate Google OAuth login for creating and managing blockchain wallets. It provides a simple interface to show a login popup, handle Google login responses, and perform various wallet-related operations such as creating wallets, getting balances, and interacting with smart contracts.

Table of Contents

Installation

Install the package using npm or yarn:

Using NPM

npm install digiffer-wallet-web

Using Yarn

yarn add digiffer-wallet-web

Then, include the DigifferWallet class in your project.

Usage

Initialization

Initialize the DigifferWallet class with the necessary configuration:

import DigifferWallet from './path/to/DigifferWallet';

const config = {
    hostUrl: 'https://your-api-host.com',
    apiKey: 'your-api-key',
    googleClientID: 'your-google-client-id'
};

const digifferWallet = new DigifferWallet(config);

Handle Login

To display the login popup, call the initLogin method with a response handler function:

  const handleLogin = async () => {
    try {
        digifferWallet.initLogin((response) => {
          console.log('Google login response:', response);
        });
    } catch (error) {
        console.error('Error in Login', error);
    }
  };
  <button onClick={handleLogin}>Login </button>

API Methods

DigifferWallet provides several methods for interacting with the wallet:

getWalletAddress(requestData)

Get the wallet address for the given user.

const requestData = { "sub_id": "user-sub-id" };
const walletData = await digifferWallet.getWalletAddress(requestData);
console.log(walletData);

getBalance(requestData)

Get the balance of the wallet.


const requestData = { "sub_id" : "user-sub-id" } // for Native token balance
const requestData = { "sub_id" : "user-sub-id", "token": "0xe954c2d9ff2a4d260dcd32386b1f9fc8135d2522" } // Custom token balance

const balance = await digifferWallet.getBalance(requestData);
console.log(balance);

readContract(requestData)

Read data from a smart contract.

const requestData= { "sub_id": "user-sub-id", "contractAddress": "Contract Address Here", "contractABI": [], "functionName": "contract-function-name", "functionArguments": "Function aruguments (Leave Blank if empty) " }
const contractData = await digifferWallet.readContract(requestData);
console.log(contractData);

writeContract(requestData)

Write data to a smart contract.

const requestData = { "sub_id": "user-sub-id", "contractAddress": "Contract Address Here", "contractABI": [], "functionName": "contract-function-name", "functionArguments": [] }
const writeResponse = await digifferWallet.writeContract(requestData);
console.log(writeResponse);

writeMultipleOnContract(requestData)

Perform multiple transactions on a smart contract.

const requestData = { "sub_id": "user-sub-id", "transactionData": [
    {
      "contractAddress": "Contract Address Here", "contractABI": [], "functionName": "contract-function-name", "functionArguments": [] 
    }
    {
      "contractAddress": "Contract Address Here", "contractABI": [], "functionName": "contract-function-name", "functionArguments": [] 
    }
]}
const batchResponse = await digifferWallet.writeMultipleOnContract(requestData);
console.log(batchResponse);

License

This project is licensed under the MIT License.