# @randlabs/myalgo-connect

> [![npm version](https://badge.fury.io/js/@randlabs%2Fmyalgo-connect.svg)](https://badge.fury.io/js/@randlabs%2Fmyalgo-connect) [![Website shields.io](https://img.shields.io/website-up-down-green-red/http/shields.io.svg)](https://connect.myalgo.com/) [![Di

Latest version **1.4.2** (published 2022-11-28) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @randlabs/myalgo-connect
pnpm add @randlabs/myalgo-connect
yarn add @randlabs/myalgo-connect
bun add @randlabs/myalgo-connect
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.2 |
| Published | 2022-11-28 |
| First published | 2021-03-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 54.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 60 |
| Author | RandLabs.IO |
| Maintainers | mpicco-randlabs, mxmauro, alex99y |

## Links

- npm: https://www.npmjs.com/package/@randlabs/myalgo-connect
- Repository: https://github.com/randlabs/myalgo-connect
- Homepage: https://github.com/randlabs/myalgo-connect#readme
- Issues: https://github.com/randlabs/myalgo-connect/issues
- npm.io page: https://npm.io/package/@randlabs/myalgo-connect

## Dependencies (1)

- [@randlabs/communication-bridge](https://npm.io/package/@randlabs/communication-bridge.md) 1.0.1

## Recent versions

- 1.4.2 (latest) — 2022-11-28
- 1.4.1 — 2022-11-07
- 1.4.0 — 2022-10-24
- 1.3.1 — 2022-09-07
- 1.3.0 — 2022-08-24
- 1.2.0 — 2022-06-02
- 1.1.3 — 2022-04-13
- 1.1.2 — 2022-01-06
- 1.1.1 — 2021-09-01
- 1.1.0 — 2021-07-13
- 1.0.1 — 2021-03-08
- 1.0.0 — 2021-03-04

## README

# MyAlgo Connect

[![npm version](https://badge.fury.io/js/@randlabs%2Fmyalgo-connect.svg)](https://badge.fury.io/js/@randlabs%2Fmyalgo-connect)
[![Website shields.io](https://img.shields.io/website-up-down-green-red/http/shields.io.svg)](https://connect.myalgo.com/)
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.com/channels/491256308461207573/817420411502329896)
[![Twitter](https://badgen.net/badge/icon/twitter?icon=twitter&label)](https://twitter.com/myalgo_)

![myalgo-logo](brand-kit/my-algo.png)

* [Overview](#Overview)
* [Installation](#Installation)
* [API Usage](#API-Usage)
  * [Quick start](#Quick-start)
  * [Connect to My Algo](#Connect-to-My-Algo)
  * [Sign transaction](#Sign-transaction)
* [Documentation](#Documentation)
* [Copyright and License](#Copyright-and-License)

## Overview

MyAlgo Connect is a Javascript library developed by Rand Labs to securely sign transactions with [My Algo](https://wallet.myalgo.com)

## Installation  

The package can be installed via npm:

```sh
npm i @randlabs/myalgo-connect
```

or imported in the HTML

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

Find the browser minified version in our github [releases](https://github.com/randlabs/myalgo-connect/releases)

## API Usage  

### Quick start

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

### Connect to My Algo  

```js
/*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);
  }
}
```

```html
<button onclick="connectToMyAlgo()">Connect!</button>
```

### Sign transaction

```js
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](LICENSE.md) file.

---
_Source: https://npm.io/package/@randlabs/myalgo-connect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
