operate-bsv / op_agent-js

Operate JavaScript agent used to load and run Bitcoin programs.
https://www.operatebsv.org
MIT License
4 stars 3 forks source link

Operate | Agent (js)

Operate | Agent (js) is a JavaScript agent used to load and run programs (known as "tapes") encoded in Bitcoin SV transactions.

About Operate

Operate is a toolset to help developers build applications, games and services on top of Bitcoin (SV). It lets you write functions, called "Ops", and enables transactions to become small but powerful programs, capable of delivering new classes of services layered over Bitcoin.

More infomation:

Installation

Install using NPM:

npm install @operate/agent
const Operate = require('@operate/agent')

Or use in the browser via CDN (adds Operate to the global namespace):

<script src="https://github.com/operate-bsv/op_agent-js/raw/master//unpkg.com/@operate/agent@latest/dist/operate.min.js"></script>

Quick start

Aliases

To kick the styles, set up some aliases for common Bitcom protocol prefixes. This will allow you to load and run tapes from common services such as Bitpaste, Twetch, WeatherSV, Bit.sv and more.

Operate.config.quickStartAliases()

Load and run a tape

Operate can be used straight away to load and run tapes from transactions.

const tape = await Operate.loadTape(txid)
const result = await Operate.runTape(tape)

Operate always returns table structures from the Lua environment as a JavaScript Map. If preferred, these can be converted to an Object for easier data traversal and access.

Operate.util.mapToObject(result)

Beta software

This software should be considered beta. There are a few known issues and things that may change over time:

License

MIT License.

© Copyright 2020 Chronos Labs Ltd.