1.1.1 • Published 3 months ago

ohnocringe-provid3r v1.1.1

Weekly downloads
-
License
-
Repository
-
Last release
3 months ago

ohnocringe-provid3r

PREREQUISITES:

  • NodeJS 18+
  • npm / yarn (refer to package.json for specifics)

ohnocringe-provid3r is a TypeScript library designed to seamlessly connect frontend applications with MassaStation and browser wallet extensions adhering to the massa standard. This library provides a gateway to all massa-blockchain wallets, offering standardized functionalities for effortless integration.

Installation

ohnocringe-provid3r can be integrated as a library within frameworks or bundled for direct browser use.

For Frameworks (Node.js/React/Vue.js)

npm install ohnocringe-provid3r

Documentation

Ohnocringe-provid3r provides complete documentation of all available functions and objects.

To generate the documentation for a specific branch, run the following command:

npm run doc

The documentation will be generated in the docs/documentation/html directory.

Usage

Example

Ohnocringe-provid3r is meant to be used with massa-web3 but can also be used as a standalone library. Here is a simple example of how to use ohnocringe-provid3r:

import { providers } from  "ohnocringe-provid3r";


// get all available massa-wallet providers

const  providers = providers();
  

// get a provider

const  myProvider = providers[0];

console.log("Provider Name", myProvider.name());


// import an account via the massa-wallet provider

console.log("Importing an account ...");

const  privateKey = "Sxxxxxxxxxxxxxx";

const  publicKey = "Pxxxxxxxxxxxxxxx";


await  myProvider.importAccount(publicKey, privateKey);


// get accounts

console.log("Retrieving the accounts ...");

const  myAccounts = await myProvider.accounts();

console.log("Provider accounts ...", myAccounts);
  

// getting one account

const  myAccount = myAccounts[0];

console.log("Account address ", myAccount.address());
 

// getting account balance

console.log("Retrieving the account balance ...");

const  accountBalance = await myAccount.balance();

console.log("Account Balance = ", accountBalance.balance);
 

// signing a message

console.log("Signing a message ...");

const  signature = await myAccount.sign([0, 1, 2]);

console.log("Signature = ", signature);
  

// deleting an account

console.log("Deleting an account ...");

await  myProvider.importAccount(myAccount.address());