-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
80 lines (73 loc) · 2.06 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
package main
import (
"evm-inscriptions/app"
"evm-inscriptions/utils/config"
"evm-inscriptions/utils/log"
"github.com/bitxx/load-config/source/file"
"github.com/shopspring/decimal"
"time"
)
const (
//configPath = "settings.dev.yml" //测试专用
configPath = "settings.yml" //正式专用
)
func init() {
config.Setup(
file.NewSource(file.WithPath(configPath)),
)
}
func main() {
var err error
defer func() {
if err != nil {
log.Errorf("mint失败,程序终止,失败原因:%s", err)
return
}
log.Info("所有mint任务完成")
time.Sleep(3 * time.Second) //3秒种后,窗口关闭
}()
evmApp := app.NewApp()
//转eth单位精度
accuracyEth, err := decimal.NewFromString("1000000000000000000")
if err != nil {
return
}
//转Gwei单位精度
accuracyGWei, err := decimal.NewFromString("1000000000")
if err != nil {
return
}
gasPrice, err := decimal.NewFromString(config.MintConfig.GasPrice)
if err != nil {
return
}
log.Infof("欢迎使用 %s ", config.ApplicationConfig.Name)
log.Infof("当前节点地址:%s", config.ChainConfig.Url)
log.Infof("总计mint张数:%d", config.MintConfig.Times)
log.Infof("单张gas price:%sGwei", gasPrice.DivRound(accuracyGWei, 18))
log.Infof("单张gas limit:%s\n\n", config.MintConfig.GasLimit)
//开始mint
for i := 1; i <= config.MintConfig.Times; i++ {
time.Sleep(time.Duration(config.MintConfig.Delay) * time.Second) //防止多次异常,导致连续mint同一个nonce
balanceStr, er := evmApp.TokenBalanceOf()
err = er
if err != nil {
log.Errorf("第%d张读取账户余额异常,原因:%s", i, err)
continue
}
balance, er := decimal.NewFromString(balanceStr)
err = er
if err != nil {
log.Errorf("第%d张解析账户余额异常,原因:%s", i, err)
continue
}
log.Infof("当前账户余额:%s", balance.DivRound(accuracyEth, 4))
hash, er := evmApp.Mint(config.MintConfig.Data)
err = er
if err != nil {
log.Errorf("第%d张mint异常,原因:%s", i, err)
continue
}
log.Infof("第%d张mint成功,hash:%s", i, hash)
}
}