안녕하세요 @fullmi입니다.
오늘은 저번과 같이 업보팅 계산을 할건데요.
저도 잘 몰라서 데이터 분석하는데 시간이 좀 걸렸네요.
결국은 알아냈네요. account조회후 받은 데이터에서
위의 값이 임대받은 값이네요. 힘드네요 정확한 api문서가 있으면 좋으련만
예측과 추측이 난무하는 개발세상이네요.
아무튼 그리하여 완료된 소스는 아래와 같습니다.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Voteing Power</title>
<script>
.
ajax({
url: https://api.steemit.com,
type: "POST",
data: '{"id":0,"jsonrpc":"2.0","method":"database_api.find_accounts","params":{"accounts":["fullmi"]}}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
console.log(result);
var account = result.result.accounts[0];
var votingPower = account.voting_power;
//최근보팅이 얼마전에 있었는지 계산이 필요함
var sec = (new Date - new Date(account.last_vote_time + "Z")) / 1000;
//다음으로는 마지막으로 업보드한 보팅파워에 새롭게 계산된 파팅파워를 더한다.
var reVotingPower = votingPower + (10000 * sec / 432000);
//소수점 2자리까지 계산한 보팅파워 단 100%를 넘지 않는다.
reVotingPower = Math.min(reVotingPower / 100, 100).toFixed(2);
.
ajax({
url: https://api.steemit.com,
type: "POST",
data: '{"id": 0,"jsonrpc":"2.0","method":"database_api.find_accounts","params":{"accounts": ["fullmi"]}}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
console.log(r);
var response = r.result.accounts[0];
//나의 영향력.
var vestingShares = response.vesting_shares.amount / Math.pow(10, response.vesting_shares.precision);
//임대받은값
var receivedVestingShares = response.received_vesting_shares.amount / Math.pow(10, response.received_vesting_shares.precision);
console.log(vestingShares);
console.log(receivedVestingShares);
//글로벌 프로퍼티값 가져오기
(
"input[name='frm_steempower']").
val(
steemPower);
}
})
}
})
}
function e() {
var e =
(
"input[name='frm_votingpower']").
val()
,
n =
(
"#vote_value").
text(
l.
toFixed(
2)),
(
"#reward_balance").
text(
parseInt(
n).
toString().
replace(
/\B(?=(\d{3})+(?!\d))/g,
",")),
(
"#steem_price_sbd").
text(
"(
"#form_calc").
on(
"submit",
function (
t) {
e(),
t.preventDefault()
});
init();
});
</script>
</head>
<body>
<div id="mainwrapper">
<br>
<div class="topbox">Steem Price
<br>
<span class=
"value" id=
"steem_price_sbd"> <span id="vote_value">0.00</span>
</b>
</div>
<form id="form_calc" method="get" style="padding:16px;line-height:21px">
<label for="frm_steempower">
<span style="width:130px">Steem Power</span>
<input name="frm_steempower" size="6" value="10000">
</label>
<br>
<label for="frm_votingpower">
<span style="width:130px">Voting Power</span>
<input name="frm_votingpower" size="6" value="100"> %</label>
<br>
<label for="frm_voteweight">
<span style="width:130px">Vote Weight</span>
<input name="frm_voteweight" size="6" value="100"> %</label>
<br>
<label style="display:block;margin-top:14px">
<span> </span>
<input type="submit" value="Calculate">
</label>
</form>
</section>
</div>
</div>
</body>
</html>
Replies (3)
kr-event태그하셔서 왔습니다^^
보팅, 팔로우하고 갑니다~
저도 SBD 100% BACK 이벤트 진행중인데 오셔서 참여부탁드려요~
이벤트참여
오늘도 좋은하루 되세요~ :)
수고하셨습니다. :)
감사해요