我如何在NativeScript中使用web3.js库(用于Ethereum开发)?
我试过:
npm install web3@0.20.7 --saveconst Web3 =require('https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js');const Web3 = require("./web3.min.js");文件进行web3.min.js,但是console.log(Web3)只打印一个空数组。此外,我还添加了NativeScript插件本地代码-nodeify。
在前三种情况中,我得到了一个异常,上面写着“调用js方法onCreate失败”
注意:我明确地不想通过后端来处理与Ethereum的交互。
发布于 2018-10-23 14:56:37
实际上,我一直无法让web3js与NativeScript一起工作。看起来这是不可能的,例如,web3将使用浏览器与元请求进行通信。
然而,可能有一个解决方案,使用eth.js:
// in your root project directory
// NOT with nativescript sidekick !
npm install --save ethjs
tns plugin add nativescript-nodeify
// then, in your code
require("nativescript-nodeify");
const Eth = require('ethjs');然后,你可以与ethereum区块链进行交互。
编辑: TNS插件名是nativescript-nodeify
https://stackoverflow.com/questions/51782886
复制相似问题