# @algo-builder/runtime

> JavaScript implementation of Algorand runtime (transaction execution + TEAL interpreter)

Latest version **7.0.0** (published 2022-12-07) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @algo-builder/runtime
pnpm add @algo-builder/runtime
yarn add @algo-builder/runtime
bun add @algo-builder/runtime
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.0.0 |
| Published | 2022-12-07 |
| First published | 2021-03-17 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.11.0 |
| Dependencies | 20 |
| Unpacked size | 1023.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 128 |
| Maintainers | robert.zaremba |
| Keywords | smart-contracts, blockchain, algorand, dapps, javascript, tooling |

## Links

- npm: https://www.npmjs.com/package/@algo-builder/runtime
- Repository: https://github.com/scale-it/algo-builder.git
- Homepage: https://algobuilder.dev
- npm.io page: https://npm.io/package/@algo-builder/runtime

## Dependencies (20)

- [zod](https://npm.io/package/zod.md) ^3.19.1
- [sha3](https://npm.io/package/sha3.md) ^2.1.4
- [yaml](https://npm.io/package/yaml.md) ^1.10.2
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [debug](https://npm.io/package/debug.md) ^4.3.4
- [algosdk](https://npm.io/package/algosdk.md) ^1.24.0
- [elliptic](https://npm.io/package/elliptic.md) ^6.5.4
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.1.1
- [hi-base32](https://npm.io/package/hi-base32.md) ^0.5.1
- [js-sha256](https://npm.io/package/js-sha256.md) ^0.9.0
- [js-sha512](https://npm.io/package/js-sha512.md) ^0.8.0
- [rustbn.js](https://npm.io/package/rustbn.js.md) ^0.2.0
- [murmurhash](https://npm.io/package/murmurhash.md) ^2.0.1
- [tweetnacl-ts](https://npm.io/package/tweetnacl-ts.md) ^1.0.3
- [@nodelib/fs.walk](https://npm.io/package/@nodelib/fs.walk.md) ^1.2.8
- [@types/crypto-js](https://npm.io/package/@types/crypto-js.md) ^4.1.1
- [lodash.clonedeep](https://npm.io/package/lodash.clonedeep.md) ^4.5.0
- [@algo-builder/web](https://npm.io/package/@algo-builder/web.md) 7.0.0
- [@types/json-bigint](https://npm.io/package/@types/json-bigint.md) ^1.0.1
- [source-map-support](https://npm.io/package/source-map-support.md) ^0.5.21

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 7.0.0 (latest) — 2022-12-07
- 6.0.0 — 2022-11-04
- 5.0.1 — 2022-07-11
- 5.0.0 — 2022-07-08
- 4.0.0 — 2022-05-24
- 3.2.0 — 2022-02-03
- 3.1.0 — 2022-01-25
- 3.0.0 — 2021-12-21
- 2.1.0 — 2021-10-22
- 2.0.1 — 2021-10-18
- 2.0.0 — 2021-09-30
- 1.2.0 — 2021-08-09
- 1.1.2 — 2021-07-16
- 1.1.1 — 2021-07-12
- 1.1.0 — 2021-06-23
- … 3 more at https://npm.io/package/@algo-builder/runtime/versions

## README

# [Algo Builder Runtime](https://algobuilder.dev/)

This package implements a light version of the go-algorand runtime. It allows to executes transactions and processes TEAL in JavaScript environment. The packages provides 4 main object:

- [Runtime](https://github.com/scale-it/algo-builder/blob/master/packages/runtime/src/runtime.ts): handles transaction or txn group processing and state management . User can use a `Runtime` object to set up accounts, create applications, opt-in to app, update app, etc...
- [AccountStore](https://github.com/scale-it/algo-builder/blob/master/packages/runtime/src/account.ts): user can create new accounts using a `AccountStore` object. All information about an account (`apps`, `assets`, `localState`, `globalState` etc..) is stored in `AccountStore`.
- [Parser](https://github.com/scale-it/algo-builder/tree/master/packages/runtime/src/parser): reads TEAL code and converts it to a list of opcodes which are executable by the interpreter. If a teal code contains an invalid opcode/data, parser will throw an error.
- [Interpreter](https://github.com/scale-it/algo-builder/tree/master/packages/runtime/src/interpreter): executes a list of opcodes returned by parser. Interpreter creates teal execution stack and interacts with runtime to perform changes related a TEAL code execution. At the end of execution, if the stack contains a single non-zero uint64 element then the teal code is approved, and transaction can be executed.

## Important links

- [Home Page](https://algobuilder.dev/)
- [Runtime API Docs](https://algobuilder.dev/api/runtime/index.html)
- [User Docs](https://algobuilder.dev/guide/README)

## Usage

`@algo-builder/runtime` can be included as a library using `yarn add @algo-builder/runtime` and then import it using `import * from '@algo-builder/runtime'`.

Please read more about usage of `runtime` from [here](https://scale-it.github.io/algo-builder/guide/testing-teal.html).

## What we support now

`runtime` supports:

- Prepare account state for teal execution.
- Stateless TEAL - Approve/Reject logic.
- Stateful TEAL - Update and verify global/local states if teal logic is correct.
- Transactions to

  - [`create` an application](https://developer.algorand.org/docs/features/asc1/stateful/sdks/#create)
  - [`opt-in` to application](https://developer.algorand.org/docs/features/asc1/stateful/sdks/#opt-in)
  - [`call` application](https://developer.algorand.org/docs/features/asc1/stateful/sdks/#call-noop)
  - [`update` application](https://developer.algorand.org/docs/features/asc1/stateful/sdks/#update)
  - [`delete` application](https://developer.algorand.org/docs/features/asc1/stateful/sdks/#delete)
  - [`closeout` from an application](https://developer.algorand.org/docs/features/asc1/stateful/sdks/#close-out)
  - [`clearState` of application](https://developer.algorand.org/docs/features/asc1/stateful/sdks/#clear-state)
  - [`create` an asset](https://developer.algorand.org/docs/features/transactions/#create-an-asset)
  - [`opt-in` to asset](https://developer.algorand.org/docs/features/transactions/#asset-transfer-transaction)
  - [`transfer` an asset](https://developer.algorand.org/docs/reference/transactions/#asset-transfer-transaction)
  - [`rekey` an account](https://developer.algorand.org/docs/get-details/accounts/rekey/?from_query=rekey#create-publication-overlay)

- Full transaction processing for type `payment`, `application call`
- Asset related transactions:

  - [Asset Destroy](https://developer.algorand.org/docs/reference/transactions/#asset-configuration-transaction)
  - [Asset Revoke](https://developer.algorand.org/docs/reference/transactions/#asset-clawback-transaction)
  - [Asset Freeze](https://developer.algorand.org/docs/reference/transactions/#asset-freeze-transaction)
  - [Asset Configuration](https://developer.algorand.org/docs/reference/transactions/#asset-configuration-transaction)

- Multisignature - `Runtime` now allows to to withdraw from accounts that has been rekeyed to
  multisignature account. In order to do it:

  1. Create multisignature address with `algosdk`.
  2. Rekey account to multisig address.
  3. Sign a transaction using `algosdk`.
  4. Invoke `runtime.executeTx(SignedMultiSigTransaction)`

  More [details](https://developer.algorand.org/docs/get-details/transactions/signatures/#multisignatures).

STATUS: production ready.

## Contributing

Please read the main [README](https://github.com/scale-it/algo-builder/blob/master/README.md).

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