-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
83 lines (76 loc) · 1.96 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"net/http"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/mandrigin/gin-spa/spa"
"github.com/thrashzone13/nft-gas-fee/service"
)
func main() {
crp := service.NewCryptonatorService()
gas := service.NewEthgasService()
r := gin.Default()
r.Use(gin.Recovery())
r.Use(cors.Default())
r.GET("/price", func(c *gin.Context) {
gwei := gas.Get()
eth := crp.Get()
c.JSON(http.StatusOK, gin.H{
"status": true,
"eth": eth.ETH,
"gwei": prepareGweiData(gwei),
"contracts": map[string]map[string]int{
"art_blocks": {
"buy_nft": 503542,
},
"async_art": {
"use_control_token": 71472,
"setup_control_token": 383225,
"mint_nft": 710405,
"bid_on_nft": 183398,
},
"ephimera": {
"create_nft": 298600,
"accept_nft_bid": 151091,
"list_nft": 70135,
"withdarw_order": 58891,
"make_purchase": 145933,
},
"foundation": {
"list_nft": 314488,
"mint_nft": 315069,
"change_list_price": 32745,
"accept_bid": 264108,
"create_bid": 70620,
},
"makers_place": {
"create_release_series": 402377,
"create_release_with_media": 495429,
"accept_bid": 242427,
"create_bid": 74214,
},
"opensea": {
"register_account": 389335,
"buy_nft": 394790,
},
"zora": {
"mint_and_list": 539160,
"set_ask_price": 81630,
"accept_price": 285940,
"remove_bid": 89853,
"add_bid": 169131,
},
},
})
})
r.Use(spa.Middleware("/", "./app/build/"))
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
func prepareGweiData(gwei *service.EthgasResponse) map[string]int {
gweiData := make(map[string]int)
gweiData["low"] = gwei.SafeLow
gweiData["average"] = gwei.Average
gweiData["fast"] = gwei.Fast
gweiData["fastest"] = gwei.Fastest
return gweiData
}