├── README.md ├── abi.json ├── account.txt ├── proxies.txt ├── requirements.txt └── xterio.py /README.md: -------------------------------------------------------------------------------- 1 | # xterio_palio 2 | 3 | xterio 任务 4 | 5 | ## update 6 | 7 | 1. 0.01bnb 购买boost 8 | 2. chat任务 在文心一言申请免费api,在454行填写api_key和secret_key **或者** 直接在458行将sentence改成固定内容(不确定会不会女巫) 9 | 10 | ## config 11 | 12 | account.txt 填写账号,格式:地址,私钥 一行一个 (注意用英文逗号)不要有多余的空行 13 | proxies.txt 填写代理 格式:user:password@ip:port 一行一个,与账号对应,没有的话不填 14 | 15 | ## run 16 | 17 | ```commandline 18 | pip install -r requirements.txt 19 | python xterio.py 20 | ``` 21 | 22 | ## note 23 | 24 | 1. 336行 随机deposit 0.015-0.02的金额到xterio链,可自行修改。deposit 偶尔会失败,重新跑即可,失败只扣gas 25 | 2. 438行 填写邀请码,可改为自己的 26 | 27 | ## plan 28 | 29 | 1. 添加chatgpt接口自动生成story 30 | 31 | ## donate 32 | ERC-20: 0xa1482B19EF1a577bb87bE3BB4EFc4d1bA64f5A45 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "palio_incubator": { 3 | "contract": "0xBeEDBF1d1908174b4Fc4157aCb128dA4FFa80942", 4 | "abi": [ 5 | { 6 | "inputs": [], 7 | "name": "claimEgg", 8 | "outputs": [], 9 | "stateMutability": "nonpayable", 10 | "type": "function" 11 | }, 12 | { 13 | "inputs": [ 14 | { 15 | "internalType": "uint8", 16 | "name": "utilityType", 17 | "type": "uint8" 18 | } 19 | ], 20 | "name": "claimUtility", 21 | "outputs": [], 22 | "stateMutability": "nonpayable", 23 | "type": "function" 24 | }, 25 | { 26 | "inputs": [], 27 | "name": "boost", 28 | "outputs": [], 29 | "stateMutability": "payable", 30 | "type": "function" 31 | }, 32 | { 33 | "inputs": [], 34 | "name": "claimChatNFT", 35 | "outputs": [], 36 | "stateMutability": "nonpayable", 37 | "type": "function" 38 | } 39 | ] 40 | }, 41 | "palio_voter": { 42 | "contract": "0x73e987FB9F0b1c10db7D57b913dAa7F2Dc12b4f5", 43 | "abi": [ 44 | { 45 | "inputs": [ 46 | { 47 | "internalType": "uint256", 48 | "name": "characterIdx", 49 | "type": "uint256" 50 | }, 51 | { 52 | "internalType": "uint256", 53 | "name": "amount", 54 | "type": "uint256" 55 | }, 56 | { 57 | "internalType": "uint256", 58 | "name": "totalAmount", 59 | "type": "uint256" 60 | }, 61 | { 62 | "internalType": "uint256", 63 | "name": "expireTime", 64 | "type": "uint256" 65 | }, 66 | { 67 | "internalType": "bytes", 68 | "name": "_sig", 69 | "type": "bytes" 70 | } 71 | ], 72 | "name": "vote", 73 | "outputs": [], 74 | "stateMutability": "nonpayable", 75 | "type": "function" 76 | }, 77 | { 78 | "inputs": [ 79 | { 80 | "internalType": "address", 81 | "name": "", 82 | "type": "address" 83 | } 84 | ], 85 | "name": "userVotedAmt", 86 | "outputs": [ 87 | { 88 | "internalType": "uint256", 89 | "name": "", 90 | "type": "uint256" 91 | } 92 | ], 93 | "stateMutability": "view", 94 | "type": "function" 95 | } 96 | ] 97 | }, 98 | "deposit": { 99 | "contract": "0xc3671e7e875395314bbad175b2b7f0ef75da5339", 100 | "abi": [ 101 | { 102 | "type": "function", 103 | "name": "depositETH", 104 | "inputs": [ 105 | { 106 | "name": "_minGasLimit", 107 | "type": "uint32", 108 | "internalType": "uint32" 109 | }, 110 | { 111 | "name": "_extraData", 112 | "type": "bytes", 113 | "internalType": "bytes" 114 | } 115 | ], 116 | "outputs": [], 117 | "stateMutability": "payable" 118 | } 119 | ] 120 | } 121 | } -------------------------------------------------------------------------------- /account.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parkLGW/xterio_palio/a3e2ccf4a55c1499e7688732b63715b8537100c1/account.txt -------------------------------------------------------------------------------- /proxies.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parkLGW/xterio_palio/a3e2ccf4a55c1499e7688732b63715b8537100c1/proxies.txt -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parkLGW/xterio_palio/a3e2ccf4a55c1499e7688732b63715b8537100c1/requirements.txt -------------------------------------------------------------------------------- /xterio.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import random 3 | import time 4 | import requests 5 | import json 6 | from web3 import Web3 7 | from web3.middleware import geth_poa_middleware 8 | from loguru import logger 9 | from eth_account.messages import encode_defunct 10 | from fake_useragent import UserAgent 11 | 12 | 13 | class WenXin: 14 | def __init__(self, API_KEY, SECRET_KEY): 15 | self.API_KEY = API_KEY 16 | self.SECRET_KEY = SECRET_KEY 17 | self.model_url = { 18 | "ErnieBot-turbo": "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?", 19 | "ErnieBot": "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions?", 20 | "BLOOMZ-7B": "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/bloomz_7b1?", 21 | "Yi-34B": "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/yi_34b_chat", 22 | } 23 | self.headers = {'Content-Type': 'application/json'} 24 | 25 | def get_access_token(self): 26 | url = "https://aip.baidubce.com/oauth/2.0/token" 27 | params = {"grant_type": "client_credentials", "client_id": self.API_KEY, "client_secret": self.SECRET_KEY} 28 | return str(requests.post(url, params=params).json().get("access_token")) 29 | 30 | def get_response(self, content, model_type='ErnieBot-turbo'): 31 | url = self.model_url.get(model_type) 32 | if url is None: 33 | raise Exception("未知的模型类型") 34 | access_token = self.get_access_token() 35 | # url = url + "access_token=" + access_token 36 | payload = json.dumps({ 37 | "messages": [ 38 | { 39 | "role": "user", 40 | "content": content, 41 | }, 42 | ] 43 | }) 44 | 45 | response = requests.request("POST", url, headers=self.headers, data=payload, 46 | params={"access_token": access_token}) 47 | result = json.loads(response.text)['result'] 48 | 49 | sentences = result.split('.') 50 | max_len = 0 51 | final_sentence = '' 52 | for sent in sentences: 53 | max_len += len(sent) + 1 54 | if max_len >= 300: 55 | break 56 | final_sentence += sent + '.' 57 | 58 | return final_sentence 59 | 60 | 61 | class Xterio: 62 | def __init__(self, address, private_key, user_agent, proxies_conf=None): 63 | self.headers = { 64 | 'authority': 'api.xter.io', 65 | 'accept': '*/*', 66 | 'accept-language': 'zh-HK,zh-TW;q=0.9,zh;q=0.8', 67 | 'authorization': '', 68 | 'content-type': 'application/json', 69 | 'origin': 'https://xter.io', 70 | 'referer': 'https://xter.io/', 71 | 'sec-ch-ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"', 72 | 'sec-ch-ua-mobile': '?0', 73 | 'sec-ch-ua-platform': '"Windows"', 74 | 'sec-fetch-dest': 'empty', 75 | 'sec-fetch-mode': 'cors', 76 | 'sec-fetch-site': 'same-site', 77 | 'user-agent': user_agent, 78 | } 79 | self.address = address 80 | self.private_key = private_key 81 | self.proxies = proxies_conf 82 | self.req_proxies = proxies_conf['proxies'] if self.proxies is not None else None 83 | self.xter_rpc = "https://xterio.alt.technology" 84 | self.bsc_rpc = "https://bsc-pokt.nodies.app" 85 | 86 | def check_balance(self): 87 | w3 = Web3(Web3.HTTPProvider(self.xter_rpc, request_kwargs=self.proxies)) 88 | balance = w3.eth.get_balance(self.address) 89 | 90 | return balance 91 | 92 | def deposit2xter(self, amount): 93 | f = open('abi.json', 'r', encoding='utf-8') 94 | contract_palio = json.load(f)['deposit'] 95 | abi = contract_palio['abi'] 96 | contract_address = Web3.to_checksum_address(contract_palio['contract']) 97 | 98 | w3 = Web3(Web3.HTTPProvider(self.bsc_rpc, request_kwargs=self.proxies)) 99 | w3.middleware_onion.inject(geth_poa_middleware, layer=0) 100 | 101 | contract = w3.eth.contract(address=contract_address, abi=abi) 102 | 103 | amount = w3.to_wei(amount, 'ether') 104 | 105 | gas = contract.functions.depositETH(200000, '0x').estimate_gas( 106 | { 107 | 'from': self.address, 108 | 'value': amount, 109 | 'nonce': w3.eth.get_transaction_count(account=self.address) 110 | } 111 | ) 112 | transaction = contract.functions.depositETH(200000, '0x').build_transaction({ 113 | 'from': self.address, 114 | 'gasPrice': w3.eth.gas_price, 115 | 'nonce': w3.eth.get_transaction_count(account=self.address), 116 | 'gas': gas, 117 | 'value': amount, 118 | }) 119 | signed_transaction = w3.eth.account.sign_transaction(transaction, private_key=self.private_key) 120 | tx_hash = w3.eth.send_raw_transaction(signed_transaction.rawTransaction) 121 | w3.eth.wait_for_transaction_receipt(tx_hash) 122 | logger.info(f"存款hash:{tx_hash.hex()}") 123 | 124 | logger.info(f"deposit pending……") 125 | 126 | def get_challenge(self): 127 | response = requests.get( 128 | f'https://api.xter.io/account/v1/login/wallet/{self.address.upper()}', 129 | headers=self.headers, 130 | proxies=self.req_proxies 131 | ) 132 | 133 | res = response.json() 134 | assert res['err_code'] == 0, "获取challenge 错误❗" 135 | 136 | return res['data']['message'] 137 | 138 | def get_signature(self): 139 | message = self.get_challenge() 140 | 141 | encoded_msg = encode_defunct(text=message) 142 | signed_msg = Web3().eth.account.sign_message(encoded_msg, private_key=self.private_key) 143 | signature = signed_msg.signature.hex() 144 | 145 | return signature 146 | 147 | def sign_in(self): 148 | signature = self.get_signature() 149 | json_data = { 150 | 'address': self.address.upper(), 151 | 'type': 'eth', 152 | 'sign': signature, 153 | 'provider': 'METAMASK', 154 | 'invite_code': '', 155 | } 156 | 157 | response = requests.post('https://api.xter.io/account/v1/login/wallet', headers=self.headers, json=json_data, 158 | proxies=self.req_proxies) 159 | res = response.json() 160 | 161 | assert res['err_code'] == 0, "登录出错!" 162 | 163 | id_token = res['data']['id_token'] 164 | self.headers['authorization'] = id_token 165 | logger.info("登录成功✔") 166 | 167 | def claim_egg(self): 168 | f = open('abi.json', 'r', encoding='utf-8') 169 | contract_palio = json.load(f)['palio_incubator'] 170 | abi = contract_palio['abi'] 171 | contract_address = Web3.to_checksum_address(contract_palio['contract']) 172 | 173 | w3 = Web3(Web3.HTTPProvider(self.xter_rpc, request_kwargs=self.proxies)) 174 | w3.middleware_onion.inject(geth_poa_middleware, layer=0) 175 | 176 | contract = w3.eth.contract(address=contract_address, abi=abi) 177 | 178 | gas = contract.functions.claimEgg().estimate_gas( 179 | { 180 | 'from': self.address, 181 | 'nonce': w3.eth.get_transaction_count(account=self.address) 182 | } 183 | ) 184 | transaction = contract.functions.claimEgg().build_transaction({ 185 | 'gasPrice': w3.eth.gas_price, 186 | 'nonce': w3.eth.get_transaction_count(account=self.address), 187 | 'gas': gas 188 | }) 189 | signed_transaction = w3.eth.account.sign_transaction(transaction, private_key=self.private_key) 190 | tx_hash = w3.eth.send_raw_transaction(signed_transaction.rawTransaction) 191 | w3.eth.wait_for_transaction_receipt(tx_hash) 192 | logger.info(f"claim egg 成功✔ hash:{tx_hash.hex()}") 193 | 194 | def apply_invite(self, invite_code): 195 | json_data = { 196 | 'code': invite_code, 197 | } 198 | 199 | response = requests.post( 200 | f'https://api.xter.io/palio/v1/user/{self.address}/invite/apply', 201 | headers=self.headers, 202 | json=json_data, 203 | proxies=self.req_proxies 204 | ) 205 | 206 | res = response.json() 207 | assert res['err_code'] == 0, "填写邀请码出错!" 208 | 209 | logger.info("填写邀请码成功✔") 210 | 211 | def trigger(self, tx_hash): 212 | json_data = { 213 | 'eventType': 'PalioIncubator::*', 214 | 'network': 'XTERIO', 215 | 'txHash': tx_hash, 216 | } 217 | 218 | response = requests.post('https://api.xter.io/baas/v1/event/trigger', headers=self.headers, json=json_data, 219 | proxies=self.req_proxies) 220 | 221 | res = response.json() 222 | assert res['err_code'] == 0, "claim 失败❗" 223 | 224 | def claim_utility(self, type_num): 225 | f = open('abi.json', 'r', encoding='utf-8') 226 | contract_palio = json.load(f)['palio_incubator'] 227 | abi = contract_palio['abi'] 228 | contract_address = Web3.to_checksum_address(contract_palio['contract']) 229 | 230 | w3 = Web3(Web3.HTTPProvider(self.xter_rpc, request_kwargs=self.proxies)) 231 | w3.middleware_onion.inject(geth_poa_middleware, layer=0) 232 | 233 | contract = w3.eth.contract(address=contract_address, abi=abi) 234 | 235 | gas = contract.functions.claimUtility(type_num).estimate_gas( 236 | { 237 | 'from': self.address, 238 | 'nonce': w3.eth.get_transaction_count(account=self.address) 239 | } 240 | ) 241 | transaction = contract.functions.claimUtility(type_num).build_transaction({ 242 | 'gasPrice': w3.eth.gas_price, 243 | 'nonce': w3.eth.get_transaction_count(account=self.address), 244 | 'gas': gas 245 | }) 246 | signed_transaction = w3.eth.account.sign_transaction(transaction, private_key=self.private_key) 247 | tx_hash = w3.eth.send_raw_transaction(signed_transaction.rawTransaction) 248 | w3.eth.wait_for_transaction_receipt(tx_hash) 249 | # logs = receipt['logs'] 250 | 251 | self.trigger(tx_hash.hex()) 252 | logger.info(f"type {type_num} claim 成功✔ hash:{tx_hash.hex()}") 253 | 254 | def prop(self, type_num): 255 | json_data = { 256 | 'prop_id': type_num, 257 | } 258 | 259 | response = requests.post( 260 | f'https://api.xter.io/palio/v1/user/{self.address}/prop', 261 | headers=self.headers, 262 | json=json_data, 263 | proxies=self.req_proxies 264 | ) 265 | 266 | res = response.json() 267 | assert res['err_code'] == 0, f'prop type{type_num} 失败❗' 268 | 269 | logger.info(f"喂蛋成功({type_num}/3)✔") 270 | 271 | def get_task_list(self): 272 | response = requests.get(f'https://api.xter.io/palio/v1/user/{self.address}/task', 273 | headers=self.headers, proxies=self.req_proxies) 274 | 275 | res = response.json() 276 | 277 | assert res['err_code'] == 0, "获取任务id失败❗" 278 | 279 | task_list = res['data']['list'] 280 | 281 | return task_list 282 | 283 | def report(self, task_id): 284 | json_data = { 285 | 'task_id': task_id, 286 | } 287 | 288 | response = requests.post( 289 | f'https://api.xter.io/palio/v1/user/{self.address}/task/report', 290 | headers=self.headers, 291 | json=json_data, 292 | proxies=self.req_proxies 293 | ) 294 | 295 | res = response.json() 296 | assert res['err_code'] == 0, f"三连 {task_id} 报错!" 297 | logger.info(f"三连 {task_id} 成功✔") 298 | 299 | def task(self, task_id): 300 | json_data = { 301 | 'task_id': task_id, 302 | } 303 | 304 | response = requests.post( 305 | f'https://api.xter.io/palio/v1/user/{self.address}/task', 306 | headers=self.headers, 307 | json=json_data, 308 | proxies=self.req_proxies 309 | ) 310 | 311 | res = response.json() 312 | assert res['err_code'] == 0, f'get point 报错! task id:{task_id}' 313 | 314 | logger.info(f"task[{task_id}] get point成功✔") 315 | 316 | def get_ticket(self): 317 | response = requests.get( 318 | f'https://api.xter.io/palio/v1/user/{self.address}/ticket', 319 | headers=self.headers, 320 | proxies=self.req_proxies 321 | ) 322 | 323 | res = response.json() 324 | 325 | assert res['err_code'] == 0, f'获取票数 报错!' 326 | logger.info(f"获取票数成功✔ 当前总票数:{res['data']['total_ticket']}") 327 | 328 | return res['data']['total_ticket'] - self.get_voted_amt() 329 | 330 | def get_voted_amt(self): 331 | f = open('abi.json', 'r', encoding='utf-8') 332 | contract_palio = json.load(f)['palio_voter'] 333 | abi = contract_palio['abi'] 334 | contract_address = Web3.to_checksum_address(contract_palio['contract']) 335 | 336 | w3 = Web3(Web3.HTTPProvider(self.xter_rpc, request_kwargs=self.proxies)) 337 | w3.middleware_onion.inject(geth_poa_middleware, layer=0) 338 | 339 | contract = w3.eth.contract(address=contract_address, abi=abi) 340 | 341 | res = contract.functions.userVotedAmt(w3.to_checksum_address(self.address)).call() 342 | 343 | return res 344 | 345 | def vote_onchain(self, vote_param): 346 | f = open('abi.json', 'r', encoding='utf-8') 347 | contract_palio = json.load(f)['palio_voter'] 348 | abi = contract_palio['abi'] 349 | contract_address = Web3.to_checksum_address(contract_palio['contract']) 350 | 351 | w3 = Web3(Web3.HTTPProvider(self.xter_rpc, request_kwargs=self.proxies)) 352 | w3.middleware_onion.inject(geth_poa_middleware, layer=0) 353 | 354 | contract = w3.eth.contract(address=contract_address, abi=abi) 355 | 356 | gas = contract.functions.vote(vote_param['index'], vote_param['num'], vote_param['total_num'], 357 | vote_param['expire_time'], vote_param['sign']).estimate_gas( 358 | { 359 | 'from': self.address, 360 | 'nonce': w3.eth.get_transaction_count(account=self.address) 361 | } 362 | ) 363 | transaction = contract.functions.vote(vote_param['index'], vote_param['num'], vote_param['total_num'], 364 | vote_param['expire_time'], vote_param['sign']).build_transaction({ 365 | 'gasPrice': w3.eth.gas_price, 366 | 'nonce': w3.eth.get_transaction_count(account=self.address), 367 | 'gas': gas 368 | }) 369 | signed_transaction = w3.eth.account.sign_transaction(transaction, private_key=self.private_key) 370 | tx_hash = w3.eth.send_raw_transaction(signed_transaction.rawTransaction) 371 | w3.eth.wait_for_transaction_receipt(tx_hash) 372 | 373 | logger.info(f"投票成功✔ hash:{tx_hash.hex()}") 374 | 375 | def vote(self, ticket_num, index=0): 376 | ''' 377 | :param ticket_num: 票数 378 | :param index: 投第几个,默认第一个 379 | :return: 380 | ''' 381 | 382 | json_data = { 383 | 'index': index, 384 | 'num': ticket_num, 385 | } 386 | 387 | response = requests.post( 388 | f'https://api.xter.io/palio/v1/user/{self.address}/vote', 389 | headers=self.headers, 390 | json=json_data, 391 | proxies=self.req_proxies 392 | ) 393 | 394 | res = response.json() 395 | 396 | assert res['err_code'] == 0, '获取投票参数报错!' 397 | logger.info("获取投票参数成功✔") 398 | 399 | self.vote_onchain(res['data']) 400 | 401 | def boost(self): 402 | f = open('abi.json', 'r', encoding='utf-8') 403 | contract_palio = json.load(f)['palio_incubator'] 404 | abi = contract_palio['abi'] 405 | contract_address = Web3.to_checksum_address(contract_palio['contract']) 406 | 407 | w3 = Web3(Web3.HTTPProvider(self.xter_rpc, request_kwargs=self.proxies)) 408 | w3.middleware_onion.inject(geth_poa_middleware, layer=0) 409 | 410 | contract = w3.eth.contract(address=contract_address, abi=abi) 411 | 412 | gas = contract.functions.boost().estimate_gas( 413 | { 414 | 'from': self.address, 415 | 'nonce': w3.eth.get_transaction_count(account=self.address), 416 | 'value': w3.to_wei(0.01, 'ether'), 417 | } 418 | ) 419 | transaction = contract.functions.boost().build_transaction({ 420 | 'gasPrice': w3.eth.gas_price, 421 | 'nonce': w3.eth.get_transaction_count(account=self.address), 422 | 'gas': gas, 423 | 'value': w3.to_wei(0.01, 'ether'), 424 | }) 425 | signed_transaction = w3.eth.account.sign_transaction(transaction, private_key=self.private_key) 426 | tx_hash = w3.eth.send_raw_transaction(signed_transaction.rawTransaction) 427 | w3.eth.wait_for_transaction_receipt(tx_hash) 428 | 429 | self.trigger(tx_hash.hex()) 430 | logger.info(f"boost 成功✔ hash:{tx_hash.hex()}") 431 | 432 | def send_story(self): 433 | headers = { 434 | 'Accept': '*/*', 435 | 'Accept-Language': 'zh-HK,zh-TW;q=0.9,zh;q=0.8', 436 | 'Authorization': self.headers['authorization'], 437 | 'Connection': 'keep-alive', 438 | 'Content-Type': 'text/plain;charset=UTF-8', 439 | 'Origin': 'https://xter.io', 440 | 'Referer': 'https://xter.io/', 441 | 'Sec-Fetch-Dest': 'empty', 442 | 'Sec-Fetch-Mode': 'cors', 443 | 'Sec-Fetch-Site': 'cross-site', 444 | 'User-Agent': self.headers['user-agent'], 445 | 'sec-ch-ua': '"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"', 446 | 'sec-ch-ua-mobile': '?0', 447 | 'sec-ch-ua-platform': '"Windows"', 448 | } 449 | 450 | params = { 451 | 'address': self.address, 452 | } 453 | 454 | wx = WenXin(API_KEY='', SECRET_KEY='') 455 | content = "I've got a teeny-tiny question, can you tell me, what is ”SADNESS“? Is sadness like when the sun goes away in the sky and the whole world gets really quiet?\nYou need to control the number of response characters to not exceed 300." 456 | sentence = wx.get_response(content, "Yi-34B") 457 | 458 | # sentence = "你复制的内容" 459 | 460 | j_data = { 461 | "answer": sentence 462 | } 463 | 464 | response = requests.post( 465 | 'https://3656kxpioifv7aumlcwe6zcqaa0eeiab.lambda-url.eu-central-1.on.aws/', 466 | params=params, 467 | headers=headers, 468 | data=json.dumps(j_data), 469 | proxies=self.req_proxies 470 | ) 471 | 472 | score = 0 473 | for line in response.iter_lines(): 474 | if line: 475 | data = json.loads(line) 476 | if data.get('score'): 477 | score = data['score'] 478 | 479 | logger.info(f"最终得分:{score}") 480 | 481 | def claim_chat_nft(self): 482 | f = open('abi.json', 'r', encoding='utf-8') 483 | contract_palio = json.load(f)['palio_incubator'] 484 | abi = contract_palio['abi'] 485 | contract_address = Web3.to_checksum_address(contract_palio['contract']) 486 | 487 | w3 = Web3(Web3.HTTPProvider(self.xter_rpc, request_kwargs=self.proxies)) 488 | w3.middleware_onion.inject(geth_poa_middleware, layer=0) 489 | 490 | contract = w3.eth.contract(address=contract_address, abi=abi) 491 | 492 | gas = contract.functions.claimChatNFT().estimate_gas( 493 | { 494 | 'from': self.address, 495 | 'nonce': w3.eth.get_transaction_count(account=self.address) 496 | } 497 | ) 498 | transaction = contract.functions.claimChatNFT().build_transaction({ 499 | 'gasPrice': w3.eth.gas_price, 500 | 'nonce': w3.eth.get_transaction_count(account=self.address), 501 | 'gas': gas 502 | }) 503 | signed_transaction = w3.eth.account.sign_transaction(transaction, private_key=self.private_key) 504 | tx_hash = w3.eth.send_raw_transaction(signed_transaction.rawTransaction) 505 | w3.eth.wait_for_transaction_receipt(tx_hash) 506 | 507 | self.trigger(tx_hash.hex()) 508 | logger.info(f"chat nft claim 成功✔ hash:{tx_hash.hex()}") 509 | 510 | 511 | async def new_account_start(semaphore, invite_code, address, private_key, proxies_conf): 512 | async with semaphore: 513 | try: 514 | xter_obj = Xterio(address, private_key, UserAgent().random, proxies_conf) 515 | 516 | balance = xter_obj.check_balance() 517 | if balance == 0: 518 | # 0.01-0.02之间随机bnb 519 | random_amount = round(random.uniform(0.015, 0.02), 3) 520 | xter_obj.deposit2xter(random_amount) 521 | 522 | loop_times = 20 523 | while balance == 0 and loop_times > 0: 524 | time.sleep(6) 525 | balance = xter_obj.check_balance() 526 | loop_times -= 1 527 | 528 | if balance == 0: 529 | logger.error(f"{address} deposit BNB 失败") 530 | return 531 | 532 | logger.info(f"deposit {random_amount}BNB 成功") 533 | 534 | xter_obj.sign_in() 535 | time.sleep(3) 536 | 537 | xter_obj.claim_egg() 538 | time.sleep(3) 539 | 540 | xter_obj.apply_invite(invite_code) 541 | 542 | # 社交任务 ids=[13,14,17] 543 | social_task_ids = [13, 14, 17] 544 | for social_task_id in social_task_ids: 545 | xter_obj.report(social_task_id) 546 | time.sleep(3) 547 | 548 | except Exception as e: 549 | logger.error(f"{address} 执行失败 msg:{e}") 550 | 551 | 552 | async def daily_start(semaphore, address, private_key, proxies_conf): 553 | async with semaphore: 554 | try: 555 | xter_obj = Xterio(address, private_key, UserAgent().random, proxies_conf) 556 | 557 | xter_obj.sign_in() 558 | time.sleep(3) 559 | 560 | for type_num in [1, 2, 3]: 561 | xter_obj.claim_utility(type_num) 562 | time.sleep(3) 563 | 564 | time.sleep(5) 565 | for type_num in [1, 2, 3]: 566 | xter_obj.prop(type_num) 567 | time.sleep(3) 568 | 569 | task_list = xter_obj.get_task_list() 570 | for task in task_list: 571 | task_id = task['ID'] 572 | for user_task in task['user_task']: 573 | if user_task['status'] == 1: 574 | xter_obj.task(task_id) 575 | time.sleep(3) 576 | 577 | # 投票,可以先注释掉,统一投 578 | # ticket_num = xter_obj.get_ticket() 579 | # if ticket_num > 0: 580 | # xter_obj.vote(ticket_num, 0) 581 | except Exception as e: 582 | logger.error(f"{address} 执行失败 msg:{e}") 583 | 584 | 585 | async def boost_purchase(semaphore, address, private_key, proxies_conf): 586 | async with semaphore: 587 | try: 588 | xter_obj = Xterio(address, private_key, UserAgent().random, proxies_conf) 589 | xter_obj.sign_in() 590 | xter_obj.boost() 591 | except Exception as e: 592 | logger.error(f"{address} 执行失败 msg:{e}") 593 | 594 | 595 | async def main(run_type, invite_code): 596 | f = open('account.txt', 'r', encoding='utf-8') 597 | accounts = f.readlines() 598 | f.close() 599 | 600 | f = open('proxies.txt', 'r', encoding='utf-8') 601 | proxies = f.readlines() 602 | f.close() 603 | 604 | # 并发数,默认10 605 | semaphore = asyncio.Semaphore(int(10)) 606 | missions = [] 607 | for idx, account in enumerate(accounts): 608 | account_parts = account.split(',') 609 | address = Web3.to_checksum_address(account_parts[0].strip()) 610 | private_key = account_parts[1].strip() 611 | 612 | proxies_conf = None 613 | if len(proxies) != 0: 614 | proxy = proxies[idx].strip() 615 | proxies_conf = { 616 | "proxies": { 617 | "http": f"socks5://{proxy}", 618 | "https": f"socks5://{proxy}" 619 | } 620 | } 621 | 622 | if run_type == 1: 623 | missions.append( 624 | asyncio.create_task(new_account_start(semaphore, invite_code, address, private_key, proxies_conf))) 625 | elif run_type == 2: 626 | missions.append(asyncio.create_task(daily_start(semaphore, address, private_key, proxies_conf))) 627 | elif run_type == 3: 628 | missions.append(asyncio.create_task(boost_purchase(semaphore, address, private_key, proxies_conf))) 629 | elif run_type == 4: 630 | missions.append(asyncio.create_task(send_chat(semaphore, address, private_key, proxies_conf))) 631 | await asyncio.gather(*missions) 632 | 633 | 634 | async def send_chat(semaphore, address, private_key, proxies_conf): 635 | async with semaphore: 636 | try: 637 | xter_obj = Xterio(address, private_key, UserAgent().random, proxies_conf) 638 | 639 | xter_obj.sign_in() 640 | time.sleep(3) 641 | 642 | xter_obj.send_story() 643 | xter_obj.claim_chat_nft() 644 | time.sleep(3) 645 | xter_obj.report(18) 646 | 647 | task_list = xter_obj.get_task_list() 648 | for task in task_list: 649 | task_id = task['ID'] 650 | for user_task in task['user_task']: 651 | if user_task['status'] == 1: 652 | try: 653 | xter_obj.task(task_id) 654 | time.sleep(3) 655 | except Exception as e1: 656 | logger.error(e1) 657 | 658 | except Exception as e: 659 | logger.error(f"{address} 执行失败 msg:{e}") 660 | 661 | 662 | if __name__ == '__main__': 663 | invite_code = "f076f883fd1503fb614731a1a20bb1c4" 664 | run_type = input("选择:\n 1. 新注册帐号 \n 2. 日常签到 \n 3. 购买boost \n 4. chat 任务 \n输入:") 665 | asyncio.run(main(int(run_type), invite_code)) 666 | --------------------------------------------------------------------------------