Skip to content

Commit 2d83960

Browse files
committed
progress calculation
1 parent c569ef3 commit 2d83960

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

direct_progress.rb

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'net/http'
2+
require 'json'
3+
4+
def get_direct_remain
5+
direct_url = "https://api.etherscan.io/api?module=stats&action=tokensupply&contractaddress=0x887834D3b8D450B6bAB109c252Df3DA286d73CE4&apikey=AWEG6NREPDJXSKZYQHTMBHZFN5FSBZF3VR"
6+
7+
resp = Net::HTTP.get_response(URI.parse(direct_url))
8+
result = JSON.parse(resp.body)
9+
10+
total = 20_000_000
11+
issued = result["result"].to_i / 10**18
12+
13+
direct_remain = total - issued
14+
rescue
15+
0
16+
end
17+
18+
19+
ico_goal = 20_000_000
20+
raised = ico_goal - get_direct_remain
21+
22+
progress = raised.to_f / ico_goal
23+
output = { progress: (progress * 100).to_i }
24+
25+
26+
File.open('./progress.json', 'w') { |file|
27+
file.write(JSON.pretty_generate(output))
28+
}

progress.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"progress": 99
3+
}

0 commit comments

Comments
 (0)