| 12
 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
 
 | from read_wallet import wallet_address, wallet_private_keyfrom connect_chain import w3
 import json
 
 contract_address = "0x7446E2F30E2C8A8AB665eB9413E8A60c062dA53C"
 
 with open("contract_abi.json", "r") as abi_file:
 contract_abi = json.load(abi_file)
 
 contract = w3.eth.contract(address=contract_address, abi=contract_abi)
 
 print(f"[CONTRACT] 加载了一个合约,其地址为:{contract_address}")
 
 def send_transaction(transaction, private_key):
 signed_transaction = w3.eth.account.sign_transaction(
 transaction, private_key)
 transaction_hash = w3.eth.send_raw_transaction(
 signed_transaction.rawTransaction)
 print(f"[TRANSACTION] 发送了一个交易,其哈希为:{transaction_hash.hex()}")
 print(f"[TRANSACTION] 正在等待交易确认......")
 
 transfer_receipt = w3.eth.wait_for_transaction_receipt(transaction_hash)
 
 print("[DEBUG]", transfer_receipt)
 print(f"[TRANSACTION] 交易已被确认。")
 
 return transaction_hash
 
 def buy_shards(value: int, wallet_address: str, private_key: str):
 transaction = contract.functions.buyShards().build_transaction({
 "chainId": 17069,
 "maxFeePerGas": w3.to_wei(1.000000014, 'gwei'),
 "maxPriorityFeePerGas": w3.to_wei(1, 'gwei'),
 "gas": 0x200000,
 "value": w3.to_wei(value, 'ether'),
 "nonce": w3.eth.get_transaction_count(wallet_address),
 })
 return send_transaction(transaction, private_key)
 
 def redeeming_paralyzing_ring(key: str, wallet_address: str, private_key: str):
 transaction = contract.functions.redeemingParalyzingRing(
 bytes(key.rjust(10, '\0'), 'utf-8')).build_transaction({
 "chainId": 17069,
 "maxFeePerGas": w3.to_wei(1.000000014, 'gwei'),
 "maxPriorityFeePerGas": w3.to_wei(1, 'gwei'),
 "gas": 0x200000,
 "value": w3.to_wei(0, 'ether'),
 "nonce": w3.eth.get_transaction_count(wallet_address),
 })
 return send_transaction(transaction, private_key)
 
 def is_solved():
 return contract.functions.isSolved().call()
 
 def transfers_of_items(amount: int, to_address: str, wallet_address: str, private_key: str):
 transaction = contract.functions.transfersOfItems(to_address, amount).build_transaction({
 "chainId": 17069,
 "maxFeePerGas": w3.to_wei(1.000000014, 'gwei'),
 "maxPriorityFeePerGas": w3.to_wei(1, 'gwei'),
 "gas": 0x200000,
 "value": w3.to_wei(0, 'ether'),
 "nonce": w3.eth.get_transaction_count(wallet_address),
 })
 return send_transaction(transaction, private_key)
 
 if __name__ == "__main__":
 
 print(redeeming_paralyzing_ring("shctf2o23",
 wallet_address, wallet_private_key).hex())
 
 
 transfer_receipt = w3.eth.get_transaction_receipt(transfer)
 
 print("[DEBUG]", transfer_receipt.__dict__.items())
 
 |