# Follow Otomate launches and trade them, in about 30 lines (Python 3.9+): pip install web3 # PRIVATE_KEY=0x… python quickstart.py — uses ETH on WETH pairs; 0.001 ETH per buy. Read the docs before risking funds. import json, os, time, urllib.request from web3 import Web3 API = os.environ.get("OTOMATE_API", "https://api.otomate.fun") + "/api/v1/ink" w3 = Web3(Web3.HTTPProvider(os.environ.get("RPC_URL", "https://rpc-qnd.inkonchain.com"))) me = w3.eth.account.from_key(os.environ["PRIVATE_KEY"]) def send(built): # sign and send one transaction the API built, wait for its receipt tx = {"to": Web3.to_checksum_address(built["to"]), "data": built["data"], "value": int(built["value"]), "from": me.address, "chainId": 57073, "nonce": w3.eth.get_transaction_count(me.address), "maxFeePerGas": w3.eth.gas_price * 2, "maxPriorityFeePerGas": w3.eth.max_priority_fee} tx["gas"] = int(built["gas"]) if built.get("gas") else w3.eth.estimate_gas(tx) * 13 // 10 # the API's limit, else the estimate + 30 % return w3.eth.wait_for_transaction_receipt(w3.eth.send_raw_transaction(me.sign_transaction(tx).raw_transaction)) def buy(token, wei): # the API quotes on chain and builds the router call (ETH in on WETH pairs) body = json.dumps({"token": token, "side": "buy", "amountIn": str(wei), "account": me.address, "nativeEth": True}).encode() built = json.load(urllib.request.urlopen(urllib.request.Request(API + "/swap-transaction", body, {"content-type": "application/json"}))) for approval in built["approvals"]: send(approval) return built["quote"]["amountOut"]["decimal"], send(built["transaction"]) with urllib.request.urlopen(API + "/feed?topics=launch") as stream: # server-sent events, one JSON per data line for line in stream: if not line.startswith(b"data: "): continue e = json.loads(line[6:]) if e["type"] == "reorg": print("reorg: drop what you stored above block", e["afterBlock"]) if e["type"] != "launch" or e["data"]["quote"] != "0x4200000000000000000000000000000000000006": continue print("new launch", e["data"]["symbol"], e["token"]) time.sleep(max(0, e["data"]["launchedAt"] + e["data"]["surcharge"]["duration"] + 1 - time.time())) # launch protection out, receipt = buy(e["token"], 10**15) print("bought", out, "tokens, tx", receipt["transactionHash"].hex())