@randlabs/myalgo-connect
TypeScript icon, indicating that this package has built-in type declarations

1.4.2 • Public • Published

MyAlgo Connect

npm version Website shields.io Discord Twitter

myalgo-logo

Overview

MyAlgo Connect is a Javascript library developed by Rand Labs to securely sign transactions with My Algo

Installation

The package can be installed via npm:

npm i @randlabs/myalgo-connect

or imported in the HTML

<script src="./myalgo.min.js"></script>

Find the browser minified version in our github releases

API Usage

Quick start

import MyAlgoConnect from '@randlabs/myalgo-connect';
const myAlgoWallet = new MyAlgoConnect();

Connect to My Algo

/*Warning: Browser will block pop-up if user doesn't trigger myAlgoWallet.connect() with a button interation */
async function connectToMyAlgo() {
  try {
    const accounts = await myAlgoWallet.connect();
    const addresses = accounts.map(account => account.address);
    
  } catch (err) {
    console.error(err);
  }
}
<button onclick="connectToMyAlgo()">Connect!</button>

Sign transaction

import algosdk from 'algosdk';
const algodClient = new algosdk.Algodv2('', 'https://node.algoexplorerapi.io/', 443);

/*Warning: Browser will block pop-up if user doesn't trigger myAlgoWallet.connect() with a button interation */
async function signTransaction (from, to, amount, suggestedParams) {
  try {
    const txn = algosdk.makePaymentTxnWithSuggestedParams({ suggestedParams, from, to, amount });
    const signedTxn = await myAlgoWallet.signTransaction(txn.toByte());  
    const response = await algodClient.sendRawTransaction(signedTxn.blob).do();
    console.log(response)
  } catch(err) {
    console.error(err); 
  }
};

Documentation

Documentation for this package is available here: https://connect.myalgo.com/. An example of an integration with MyAlgo Connect: https://github.com/randlabs/myalgo-connect-test

Copyright and License

See LICENSE file.

Readme

Keywords

none

Package Sidebar

Install

npm i @randlabs/myalgo-connect

Weekly Downloads

31,478

Version

1.4.2

License

Apache-2.0

Unpacked Size

55.8 kB

Total Files

15

Last publish

Collaborators

  • mpicco-randlabs
  • mxmauro
  • alex99y