Hive coding #15
HiveJs: How to delegate HivePower
by hive_coding
HTML
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
</head>
<body>
<div class="row">
<div class="col-xs-8 offset-sm-1">
<div class="row">
<div class="col-sm-6">
Username : <input type="text" id="username"><br/>
HivePower: <input type="text" id="hive"><br/><br/>
<button id="delegate">Delegate</button>
</div>
</div>
</div>
</div>
<script>
var total_vesting_fund_hive;
var total_vesting_shares;
$("#delegate").click(function() {
var vesting_shares=parseFloat(total_vesting_shares.split(" ")[0]) *parseFloat($("#hive").val()) /parseFloat(total_vesting_fund_hive.split(" ")[0]);
vesting_shares=vesting_shares.toFixed(6)+" VESTS";
hive.broadcast.delegateVestingShares("AKTIVPRIVATEKEYnevverUseOn JSFiddle", "hive-coding", $("#username").val(), vesting_shares, function(err, result) {
console.log(err, result);
});
});
hive.api.getDynamicGlobalProperties(function(err, result) {
total_vesting_fund_hive= result.total_vesting_fund_hive;
total_vesting_shares= result.total_vesting_shares;
});
</script>
</body>
</html>