在 React 中使用 Run:netwrork 和 Bitcoin SV

问题描述 投票:0回答:1

我在运行时遇到问题:网络库在我的反应应用程序中工作。我安装了 run-sdk 和 bsv 库,但是当我尝试在我的类中扩展 Run.Jig 时,出现断言错误

这是我的代码,它类似于文档示例: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;
 }
}

在我的主页上:

const jig = new SimpleStore()

jig.set('Satoshi Nakamoto')

await jig.sync()

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

好像我不能扩展Jig,我的类不能使用set方法。

另外,我尝试了网页版在head标签中导入脚本,如文档中所述,但仍然面临同样的问题。任何帮助表示赞赏

reactjs bitcoin-sv
1个回答
0
投票

如果您想在浏览器上使用 Run,您需要使用 https://github.com/runonbitcoin/sdk/blob/master/dist/run.browser.min.js 而不是“npm install run-sdk” .浏览器本身没有本地缓冲模块。 BN.toBuffer 是它抛出错误的地方。

© www.soinside.com 2019 - 2024. All rights reserved.