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/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>
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:
© Copyright 2020 Chronos Labs Ltd.