1

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

Marcel Gruber
  • 6,668
  • 6
  • 34
  • 60
Milos
  • 31
  • 1
  • 6

1 Answers1

1

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.

  • I tried to put the minified version in my application, but I can see the same error. Is there any known explanation for implementing this library using the browser? – Milos Oct 27 '22 at 08:08