Operate | Agent (js) is a JavaScript agent used to load and run programs (known as "tapes") encoded in Bitcoin SV transactions.
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:
Install using NPM:
npm install @operate/agentconst Operate = require('@operate/agent')Or use in the browser via CDN (adds Operate to the global namespace):
<script src="//unpkg.com/@operate/agent@latest/dist/operate.min.js"></script>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()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)This software should be considered beta. There are a few known issues and things that may change over time:
- API changes. The current implmentation closely mirrors the design of the Elixir agent. Elixir and JavaScript semantics are quite different so over time the API design may change to reflect more idiomatic JavaScript styles.
- Error handling sucks. If something goes wrong, especially in the Lua VM, the error you get back will almost certainly not be very useful. This will be improved over time.
- Bundle size. The minimised bundle currently weighs in at over 700kb! I think it will be possible to get this under 300kb, but this will take work and time.
© Copyright 2020 Chronos Labs Ltd.