在开始之前,需要安装项目依赖:
npm install
首先下载代码https://github.com/okx/js-wallet-sdk,看Build Locally部分在本地构建 Core-Bitcoin:
sh build.sh
完成后,会在项目目录中找到编译后的 Core-Bitcoin。
将编译后的 Core-Bitcoin 放到 src
目录下,并使用以下命令将其添加到的项目中:
npm install {core-bitcoin的路径}
这将在 package.json
中添加如下条目:
"@okxweb3/coin-bitcoin": "file:src/coin-bitcoin",
"@okxweb3/crypto-lib": "^1.0.1",
为了确保依赖正确解析,需要修改 node_modules/react-scripts/config
中的 resolve
配置:
fallback: {
"buffer": require.resolve("buffer/"),
"stream": require.resolve("stream-browserify")
}
此外,为了解决在 Core-Bitcoin 中遇到的 React Uncaught ReferenceError: Buffer is not defined
错误,请在出错的文件中添加以下导入:
import { Buffer } from 'buffer';
一切就绪后,可以使用以下命令来启动项目:
npm start
unisat最新版本开始支持rune v1.3.0:
https://github.com/unisat-wallet/extension/releases