-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathDeployContracts.py
208 lines (183 loc) · 6.94 KB
/
DeployContracts.py
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import os
import random
import re
import subprocess
import shutil
# 切换到当前目录
current_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(current_dir)
# 执行命令
def runCommand(command):
result = subprocess.run(command, shell=True, capture_output=True, text=True)
return result.stdout
# ERC20代币
def deployErc20(private):
curr_dir = current_dir + '/SOLIDITY/02/'
print(f'[-] 尝试部署ERC20合约...')
# 创建私钥文件
with open(curr_dir+'.env', 'w') as f:
f.write(f"PRIVATE_KEY={private}\n")
print(f"[√] .env 文件已创建并写入私钥信息")
# 部署合约
try:
os.chdir(curr_dir)
command1 = 'forge script CounterScript --broadcast --chain-id 336 --rpc-url https://mevm.devnet.m1.movementlabs.xyz/v1 --legacy'
cmd1_log = runCommand(command1)
print(cmd1_log)
print(f'[√] ERC20 部署成功!')
except Exception as e:
print(f'[x] 部署失败! {e}')
# Faucet
def deployFaucet(private):
curr_dir = current_dir + '/SOLIDITY/03/'
print(f'[-] 尝试部署Faucet合约...')
# 创建私钥文件
with open(curr_dir + '.env', 'w') as f:
f.write(f"PRIVATE_KEY={private}\n")
print(f"[√] .env 文件已创建并写入私钥信息")
# 部署合约
try:
os.chdir(curr_dir)
command1 = 'forge script CounterScript --broadcast --chain-id 336 --rpc-url https://mevm.devnet.m1.movementlabs.xyz/v1 --legacy'
cmd1_log = runCommand(command1)
print(cmd1_log)
print(f'[√] Faucet 部署成功!')
except Exception as e:
print(f'[x] 部署失败! {e}')
# Airdrop
def deployAirdrop(private):
curr_dir = current_dir + '/SOLIDITY/04/'
print(f'[-] 尝试部署Airdrop合约...')
# 创建私钥文件
with open(curr_dir + '.env', 'w') as f:
f.write(f"PRIVATE_KEY={private}\n")
print(f"[√] .env 文件已创建并写入私钥信息")
# 部署合约
try:
os.chdir(curr_dir)
command1 = 'forge script CounterScript --broadcast --chain-id 336 --rpc-url https://mevm.devnet.m1.movementlabs.xyz/v1 --legacy'
cmd1_log = runCommand(command1)
print(cmd1_log)
print(f'[√] Airdrop 部署成功!')
except Exception as e:
print(f'[x] 部署失败! {e}')
# ERC721
def deployERC721(private):
curr_dir = current_dir + '/SOLIDITY/05/'
print(f'[-] 尝试部署ERC721合约...')
# 创建私钥文件
with open(curr_dir + '.env', 'w') as f:
f.write(f"PRIVATE_KEY={private}\n")
print(f"[√] .env 文件已创建并写入私钥信息")
# 部署合约
try:
os.chdir(curr_dir)
command1 = 'forge script CounterScript --broadcast --chain-id 336 --rpc-url https://mevm.devnet.m1.movementlabs.xyz/v1 --legacy'
cmd1_log = runCommand(command1)
print(cmd1_log)
print(f'[√] ERC721 部署成功!')
except Exception as e:
print(f'[x] 部署失败! {e}')
# MerkleTree
def deployMerkleTree(private):
curr_dir = current_dir + '/SOLIDITY/06/'
print(f'[-] 尝试部署MerkleTree合约...')
# 创建私钥文件
with open(curr_dir + '.env', 'w') as f:
f.write(f"PRIVATE_KEY={private}\n")
print(f"[√] .env 文件已创建并写入私钥信息")
# 部署合约
try:
os.chdir(curr_dir)
command1 = 'forge script CounterScript --broadcast --chain-id 336 --rpc-url https://mevm.devnet.m1.movementlabs.xyz/v1 --legacy'
cmd1_log = runCommand(command1)
print(cmd1_log)
print(f'[√] MerkleTree 部署成功!')
except Exception as e:
print(f'[x] 部署失败! {e}')
# Signature
def deploySignature(private):
curr_dir = current_dir + '/SOLIDITY/07/'
print(f'[-] 尝试部署Signature合约...')
# 创建私钥文件
with open(curr_dir + '.env', 'w') as f:
f.write(f"PRIVATE_KEY={private}\n")
print(f"[√] .env 文件已创建并写入私钥信息")
# 部署合约
try:
os.chdir(curr_dir)
command1 = 'forge script CounterScript --broadcast --chain-id 336 --rpc-url https://mevm.devnet.m1.movementlabs.xyz/v1 --legacy'
cmd1_log = runCommand(command1)
print(cmd1_log)
print(f'[√] Signature 部署成功!')
except Exception as e:
print(f'[x] 部署失败! {e}')
# NFTSwap
def deployNFTSwap(private):
curr_dir = current_dir + '/SOLIDITY/08/'
print(f'[-] 尝试部署NFTSwap合约...')
# 创建私钥文件
with open(curr_dir + '.env', 'w') as f:
f.write(f"PRIVATE_KEY={private}\n")
print(f"[√] .env 文件已创建并写入私钥信息")
# 部署合约
try:
os.chdir(curr_dir)
command1 = 'forge script CounterScript --broadcast --chain-id 336 --rpc-url https://mevm.devnet.m1.movementlabs.xyz/v1 --legacy'
cmd1_log = runCommand(command1)
print(cmd1_log)
print(f'[√] NFTSwap 部署成功!')
except Exception as e:
print(f'[x] 部署失败! {e}')
# ERC1155
def deployERC1155(private):
curr_dir = current_dir + '/SOLIDITY/09/'
print(f'[-] 尝试部署ERC1155合约...')
# 创建私钥文件
with open(curr_dir + '.env', 'w') as f:
f.write(f"PRIVATE_KEY={private}\n")
print(f"[√] .env 文件已创建并写入私钥信息")
# 部署合约
try:
os.chdir(curr_dir)
command1 = 'forge script CounterScript --broadcast --chain-id 336 --rpc-url https://mevm.devnet.m1.movementlabs.xyz/v1 --legacy'
cmd1_log = runCommand(command1)
print(cmd1_log)
print(f'[√] ERC1155 部署成功!')
except Exception as e:
print(f'[x] 部署失败! {e}')
# TokenVesting
def deployTokenVesting(private):
curr_dir = current_dir + '/SOLIDITY/10/'
print(f'[-] 尝试部署TokenVesting合约...')
# 创建私钥文件
with open(curr_dir + '.env', 'w') as f:
f.write(f"PRIVATE_KEY={private}\n")
print(f"[√] .env 文件已创建并写入私钥信息")
# 部署合约
try:
os.chdir(curr_dir)
command1 = 'forge script CounterScript --broadcast --chain-id 336 --rpc-url https://mevm.devnet.m1.movementlabs.xyz/v1 --legacy'
cmd1_log = runCommand(command1)
print(cmd1_log)
print(f'[√] TokenVesting 部署成功!')
except Exception as e:
print(f'[x] 部署失败! {e}')
if __name__ == '__main__':
funcs = [deployErc20, deployFaucet ,deployAirdrop,deployERC721,deployMerkleTree,deploySignature,deployNFTSwap,deployERC1155,deployTokenVesting]
with open('seeds.txt') as f:
file = f.readlines()
PRIVATE_KEY = []
for x in file:
line = x.rstrip()
PRIVATE_KEY.append(line.split(':')[1])
for p in PRIVATE_KEY:
random.choice(funcs)(p)
#deployErc20(p)
#deployFaucet(p)
#deployAirdrop(p)
#deployMerkleTree(p)
#deploySignature(p)
#deployNFTSwap(p)
#deployERC1155(p)
#deployTokenVesting(p)