求creator 3.0 npm 引入 web3的方法

不错,感谢大神支招

大佬 你这问题解决了吗?

这个方式能具体讲一下吗?

你是遇到了什么问题?

引入Web3报错问题呢

引入Web3报错问题,运行报错!

import web3 from "web3/dist/web3.min.js"

用大佬的办法可行

半年了哈,斗胆过来问老铁要一份web3.d.ts :rofl:应该不过分吧

这个在web3的包里有提供,你找一下

1赞

但是还不能直接在creator 里引用,只能按楼上的方法

1赞

2.x版本的有救吗?还是报web3 undefined.

大佬,2.4.6报错

load script [web3] failed : Error: Cannot find module ‘bn’

还有救没

SyntaxError: Unexpected token (247:12) while parsing E:/game/node_modules/web3-eth-accounts/lib/index.js
at DestroyableTransform.end [as _flush] (D:\CocosDashboard_1.0.20\resources.editors\Creator\2.4.6\resources\app.asar\node_modules\insert-module-globals\index.js:96:21)
at DestroyableTransform.prefinish (D:\CocosDashboard_1.0.20\resources.editors\Creator\2.4.6\resources\app.asar\node_modules\readable-stream\lib_stream_transform.js:138:10)
at DestroyableTransform.emit (events.js:315:20)
at DestroyableTransform.emit (domain.js:483:12)
at prefinish (D:\CocosDashboard_1.0.20\resources.editors\Creator\2.4.6\resources\app.asar\node_modules\readable-stream\lib_stream_writable.js:619:14)
at finishMaybe (D:\CocosDashboard_1.0.20\resources.editors\Creator\2.4.6\resources\app.asar\node_modules\readable-stream\lib_stream_writable.js:627:5)
at endWritable (D:\CocosDashboard_1.0.20\resources.editors\Creator\2.4.6\resources\app.asar\node_modules\readable-stream\lib_stream_writable.js:638:3)
at DestroyableTransform.end (D:\CocosDashboard_1.0.20\resources.editors\Creator\2.4.6\resources\app.asar\node_modules\readable-stream\lib_stream_writable.js:594:41)
at Readable.onend (_stream_readable.js:681:10)
at Object.onceWrapper (events.js:421:28)
type: ‘syntax’,
filename: ‘E:/hunter/game/node_modules/web3-eth-accounts/lib/index.js’

2.x 我不清楚哦

封装了一个兼容npm的包,带类型定义,供参考: Schiznitz/web3cocos (github.com)

1赞

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。