2.0.0 • Published 1 year ago

digiffer-wallet-web v2.0.0

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

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: 'tokenAddress' } // Custom token balance

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

readContract(requestData)

Read data from a smart contract.

const requestData= { sub_id: "your-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: "your-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: "your-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.

2.0.0

1 year ago

1.7.8

1 year ago

1.7.7

1 year ago

1.7.6

1 year ago

1.7.5

1 year ago

1.7.4

1 year ago

1.7.3

1 year ago

1.7.2

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

1.6.9

1 year ago

1.6.8

1 year ago

1.6.7

1 year ago

1.6.6

1 year ago

1.6.5

1 year ago

1.6.4

1 year ago

1.6.3

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.9

1 year ago

1.5.8

1 year ago

1.5.7

1 year ago

1.5.6

1 year ago

1.5.5

1 year ago

1.5.4

1 year ago

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.9

1 year ago

1.4.8

1 year ago

1.4.7

1 year ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.9

1 year ago

1.3.8

1 year ago

1.3.7

1 year ago

1.3.6

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

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.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.9

1 year ago

1.1.8

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.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago