Skip to content

Browser package to bring access to MyAlgo Wallet accounts to dApps

License

Notifications You must be signed in to change notification settings

Gengirlily/myalgo-connect

 
 

Repository files navigation

Wallet My Algo

npm version Website shields.io Discord Twitter

myalgo-logo

Overview

Wallet My Algo 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://api.algoexplorer.io/', '');

/*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.

About

Browser package to bring access to MyAlgo Wallet accounts to dApps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 74.1%
  • HTML 20.9%
  • CSS 5.0%