Using Run:netwrork with Bitcoin SV in react

62 Views Asked by At

I have a problem getting the run:network library works in my react application. I installed run-sdk and bsv library, but when I try to extend the Run.Jig in my class I get an assertion error enter image description here

This is my code, it is similar to the documentation example on: https://run.network/docs/#introduction

const Run = require('run-sdk');


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

class SimpleStore extends Run.Jig { //this seems to be a problem 

 set(value) {
 this.value = value;
 }
}

on my Home page :

const jig = new SimpleStore()

jig.set('Satoshi Nakamoto')

await jig.sync()

console.log(jig.owner)
console.log(jig.location)
console.log(jig.origin)

It seems like I can't extend Jig, and my class can't use the set method.

Also, I tried the web version importing scripts in the head tag, as explained in the documentation, but still facing the same issue. Any help is appreciated

1

There are 1 best solutions below

1
On

If you want to use Run on the browser you need to use https://github.com/runonbitcoin/sdk/blob/master/dist/run.browser.min.js instead of "npm install run-sdk". The browser itself doesn't have a native buffer module. BN.toBuffer is where it throws the error.