Difference between revisions of "Installing the run sdk"

From RunWiki
Jump to: navigation, search
Line 41: Line 41:
 
const run = new Run({ network: 'mock' })
 
const run = new Run({ network: 'mock' })
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
<p>After that you are ready to [[Creating and_loading_jigs|create and load jigs]].</p>

Revision as of 03:50, 14 December 2022

The easiest way to get the latest version is to run

npm install run-sdk

 Another solution is to download the SDK as a zip file from https://run.network/. At the time of writing this the latest version is version 0.6.37.

Getting Started

(note the following section was originally a simple copy/paste from the official doc)

Installation

If you're new to Run, let the tutorial series guide your journey to get acquainted. You can write code without installing anything. The web browser Console will be your playground.

The details written here in the Docs have example code in the sidebar on the right-hand side. Anything you read in paragraphs, you can preview in-action over there.

Run works everywhere including all major browsers, on desktop and mobile, as well as Node.js 10+ on servers. The Run SDK is written in JavaScript ES6 and uses the bsv library to build and sign transactions. To get started:

  • For a webpage: Add bsv.browser.min.js and run.browser.min.js to the <head> tag.
  • For Node.js: Run npm install run-sdk to install both the run and bsv libraries

And that's it. All your code and jigs will be saved on-chain and Run will use public APIs to interact with the Bitcoin network. You don't need to deploy any servers to use Run. All the logic works client-side.

Code

Load both bsv and run in the browser

<script src="https://unpkg.com/bsv@1.5.6"></script>
<script src="https://unpkg.com/run-sdk"></script>

Load run in Node.js

const Run = require('run-sdk')

Setup

A Run instance manages your communication with the Bitcoin network. The default network is main (Mainnet), but for development and testing, we recommend mock. Mock is an in-memory simulation blockchain that does not require funds to use. We like to call it the mockchain. For more configuration options, see API Reference: Run.

Code

const run = new Run({ network: 'mock' })

After that you are ready to create and load jigs.