Difference between revisions of "Installing the run sdk"
| (18 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | The | + | {| style="border-collapse:collapse; background-color:red;" |
| + | | style="padding:10px; text-align:center; font-weight:bold; color:white;" | | ||
| + | ALERT: This Page is Outdated and Waiting for Update | ||
| + | The current way of testing the RUN library to create tokens is to open the devtools console at [https://runcraft.io Runcraft.io], then head over to [[Creating_and_loading_jigs|creating and loading jigs]]. | ||
| + | |} | ||
| + | |||
| + | |||
| + | The easiest way to get the latest version is to run | ||
<pre> | <pre> | ||
| − | npm install run-sdk | + | [deprecated, instead retrieve the compiled sdk file from runcraft.io] npm install run-sdk |
</pre> | </pre> | ||
| − | + | Another solution is to download the SDK as a file from [https://runcraft.io/ https://runcraft.io]. At the time of writing the latest version is 0.6.37 | |
| − | |||
| − | Another solution is to download the SDK as a | ||
= Getting Started = | = Getting Started = | ||
| − | |||
| − | |||
| − | |||
| − | |||
== Installation == | == Installation == | ||
| Line 23: | Line 24: | ||
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 [https://github.com/moneybutton/bsv bsv library] to build and sign transactions. To get started: | 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 [https://github.com/moneybutton/bsv bsv library] to build and sign transactions. To get started: | ||
| − | *For a webpage: Add | + | *For a webpage: Add <code>bsv.browser.min.js</code> and <code>run.browser.min.js</code> to the <code><head></code> tag. |
| − | *For Node.js: Run npm install run-sdk to install both the run and bsv libraries | + | *For Node.js: Run <code>npm install run-sdk</code> 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. | 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. | ||
| + | |||
| + | You can also find the SDK at [https://github.com/runonbitcoin/sdk the github repo]. | ||
| + | |||
| + | === Code === | ||
| + | |||
| + | Load both bsv and run in the browser | ||
| + | |||
| + | <syntaxhighlight lang="html"> | ||
| + | <script src="https://unpkg.com/bsv@1.5.6"></script> | ||
| + | <script src="https://unpkg.com/run-sdk"></script> | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | Load run in Node.js | ||
| + | <syntaxhighlight lang="javascript"> | ||
| + | const Run = require('run-sdk') | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | == Setup == | ||
| + | A <code>Run</code> instance manages your communication with the Bitcoin network. The default network is <code>main</code> (Mainnet), but for development and testing, we recommend <code>mock</code>. 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 [https://run.network/docs/#api-reference-run API Reference: Run.] | ||
| + | |||
| + | === Code === | ||
| + | |||
| + | <syntaxhighlight lang="javascript"> | ||
| + | const run = new Run({ network: 'mock' }) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | <p>After that you are ready to [[Creating and_loading_jigs|create and load jigs]].</p> | ||
| + | |||
| + | [[Category:Documentation]] | ||
Latest revision as of 03:23, 2 March 2025
|
ALERT: This Page is Outdated and Waiting for Update The current way of testing the RUN library to create tokens is to open the devtools console at Runcraft.io, then head over to creating and loading jigs. |
The easiest way to get the latest version is to run
[deprecated, instead retrieve the compiled sdk file from runcraft.io] npm install run-sdk
Another solution is to download the SDK as a file from https://runcraft.io. At the time of writing the latest version is 0.6.37
Getting Started
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.jsandrun.browser.min.jsto the<head>tag. - For Node.js: Run
npm install run-sdkto 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.
You can also find the SDK at the github repo.
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.