XuperScan 是 XuperChain 的区块链浏览器,支持通过浏览器以可视化的方式查看区块,交易,合约等链上信息
xchain: 5.3
xuperscan: 0.11
前言
类似于fisco的webase-front,我们需要一个可视化界面查看链子的相关信息。
在部署XuperScan之前,我们先进行xchain的启动【我为了方便,只启动了一个xchain节点】,并且使用默认的端口37101
root@192-168-19-133:/yijiu/xuperScan# netstat -tunlp | grep xchain
tcp 0 0 127.0.0.1:47101 0.0.0.0:* LISTEN 3642/xchain
tcp 0 0 127.0.0.1:37621 0.0.0.0:* LISTEN 3642/xchain
tcp6 0 0 :::37200 :::* LISTEN 3642/xchain
tcp6 0 0 :::37301 :::* LISTEN 3642/xchain
tcp6 0 0 :::37101 :::* LISTEN 3642/xchain
下载xuperScan的后端执行文件
后端文件的链接
下载链接
是一个压缩包
然后我们进行解压
unzip xuperindexer-linux-amd64.zip -d xuperindexer
我们可以看下加压项目的conf目录里面的config.yaml
node: "127.0.0.1:37101" # 链子的节点ip:端口,若不是37101,需要修改后才能启动后端服务
maxWatcherNum: 10
sqliteDBPath: "./xindexer.db" # 数据保存在的文件名
bcname: "xuper"
listen: ":8088" # 后端服务启动端口
启动服务【在后端项目的根目录】
root@192-168-19-133:/yijiu/xuperScan/xuperindexer# bin/xindexer
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
A future release of golang/protobuf will delete this package,
which has long been excluded from the compatibility promise.
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
[GIN-debug] GET /v1/transactions/:id --> icode.baidu.com/baidu/blockchain/xindexer/api/v1.GetTransactions (4 handlers)
[GIN-debug] GET /v1/transactions --> icode.baidu.com/baidu/blockchain/xindexer/api/v1.GetTransactions (4 handlers)
[GIN-debug] GET /v1/blocks --> icode.baidu.com/baidu/blockchain/xindexer/api/v1.GetBlocks (4 handlers)
[GIN-debug] GET /v1/blocks/:id --> icode.baidu.com/baidu/blockchain/xindexer/api/v1.GetBlocks (4 handlers)
[GIN-debug] GET /v1/search/:id --> icode.baidu.com/baidu/blockchain/xindexer/api/v1.Search (4 handlers)
[GIN-debug] GET /v1/transaction_stats/:type --> icode.baidu.com/baidu/blockchain/xindexer/api/v1.GetTransactionStat (4 handlers)
[GIN-debug] GET /v1/transaction_stats --> icode.baidu.com/baidu/blockchain/xindexer/api/v1.GetTransactionStat (4 handlers)
[GIN-debug] GET /v1/status --> icode.baidu.com/baidu/blockchain/xindexer/api/v1.Status (4 handlers)
[GIN-debug] GET /v1/currentBlockHeight --> icode.baidu.com/baidu/blockchain/xindexer/api/v1.GetCurrentBlockHeight (4 handlers)
[GIN-debug] GET /v1/dateTxNumber --> icode.baidu.com/baidu/blockchain/xindexer/api/v1.GetDateTxNumber (4 handlers)
[GIN-debug] Listening and serving HTTP on :8088
2023/10/08 10:29:21 /home/shikenian1/AAA/xindexer/service/service.go:160 record not found
[0.130ms] [rows:0] SELECT `block_height` FROM `transactions` ORDER BY block_height desc,`transactions`.`id` LIMIT 1
如果想放在后台启动,可以这样操作
root@192-168-19-133:/yijiu/xuperScan/xuperindexer# nohup bin/xindexer &
[1] 7159
root@192-168-19-133:/yijiu/xuperScan/xuperindexer# netstat -tunlp | grep 8088
tcp6 0 0 :::8088 :::* LISTEN 7159/bin/xindexer
下载xuperScan的前端源码
使用git 将源码下载到本地
git clone https://github.com/xuperchain/xuperscan.git
官网推荐使用node 11的版本来进行依赖下载【我之前用高版本18,导入依赖失败了o(╥﹏╥)o】
进入xuperscan主目录,执行下载依赖命令
npm install
在前端项目的根目录执行启动命令
DONE Compiled successfully in 10322ms 10:32:02
App running at:
- Local: http://localhost:8080/
- Network: http://192.168.19.133:8080/
前端启动在8080端口,我们可以打开网页看一下效果
还有区块列表
点击进去,还可以看到区块里面的交易详细信息