以太坊区块链浏览器(二)开发

以太坊区块链浏览器开发,包括合约信息及链上信息展示,web3j的对应API。

更多区块链技术与应用分类:

区块链应用    区块链开发

以太坊 | Fabric | BCOS | 密码技术 | 共识算法 | 比特币其他链

通证经济传统金融场景 | 去中心化金融 | 防伪溯源 | 数据共享 | 可信存证

一.效果

 

以太坊区块链浏览器(二)开发

二. 合约信息

1.当前用户总数:

$scope.userCount = mxxData.residentCount.call().toString();

2.已分配Token数:

$scope.assingedQuark = mxxQuarkRule.alreadyAssignedAmount.call().toFixed(4);

3.下次分配Token块:

$scope.nextAssingedBlock = mxxQuarkRule.nextAssignQuarkBlock.call().toString() + "(块)";

4. 最近交易块

function updateTXList() {
 
    var currentTXnumber = web3.eth.blockNumber;
 
    $scope.txNumber = currentTXnumber;
 
    $scope.recenttransactions = [];
 
    for (var i=0; i < 10 && currentTXnumber - i >= 0; i++) { //显示十条交易记录
        $scope.recenttransactions.push(web3.eth.getTransactionFromBlock(currentTXnumber - i));
    }
}

5.最近交易

三. 链信息(ChainInfo)

1.最新块

$scope.blockNum = web3.eth.blockNumber;
 
var blockNewest = web3.eth.getBlock($scope.blockNum);

2.难度

blockNewest.difficulty;

3.totalDifficultyDividedByDifficulty

$scope.totalDifficultyDividedByDifficulty = $scope.totalDifficulty.dividedBy($scope.difficulty);

4.AltsheetsCoefficient

$scope.AltsheetsCoefficient = $scope.totalDifficultyDividedByDifficulty.dividedBy($scope.blockNum);

5.gasLimit

$scope.gasLimit = blockNewest.gasLimit;

6.格式化的time

var newDate = new Date();
 
newDate.setTime(blockNewest.timestamp*1000);
 
$scope.time = newDate.toUTCString();

7.区块链运行时间

$scope.secondsSinceBlock1 = blockNewest.timestamp - 1438226773;
 
$scope.daysSinceBlock1 = ($scope.secondsSinceBlock1 / 86400).toFixed(2);

8.已出块数

var blockBefore = web3.eth.getBlock($scope.blockNum - 1);
 
if(blockBefore!==undefined){
 
    $scope.blocktime = blockNewest.timestamp - blockBefore.timestamp;
 
}

9.最后100块评价出块时间

$scope.range1=100;
 
range = $scope.range1;//从当前往前数100
 
var blockPast = web3.eth.getBlock(Math.max($scope.blockNum - range,0));
 
if(blockBefore!==undefined){
 
    $scope.blocktimeAverage1 = ((blockNewest.timestamp - blockPast.timestamp)/range).toFixed(2);
 
}

10.整个链出块时间

range = $scope.blockNum;
 
var blockPast = web3.eth.getBlock(1);
 
if(blockBefore!==undefined){
 
    $scope.blocktimeAverageAll = ((blockNewest.timestamp - blockPast.timestamp)/range).toFixed(2);
 
}

11.是否连接(True)

$scope.isConnected = web3.isConnected();

12.API-Client Version:0.12.2 - Geth/v1.8.4-stable/linux-amd64/go1.10

$scope.versionApi = web3.version.api;
 
$scope.versionClient = web3.version.client;
 
($scope.versionNetwork = web3.version.network;
 
$scope.versionCurrency = web3.version.ethereum;)

原文链接:以太坊区块链浏览器(二)开发 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值