Solana Swap TranstoPython

Программы на Python
Anonymous
 Solana Swap Transto

Сообщение Anonymous »

Пожалуйста, помогите мне создать транзакцию по составу с использованием Solana и Setres, не так много документов для Python и многих устаревших примеров
Использование Solana 0.36 и припов 0,23
# 1) Get a single quote object
quote_url = (
"https://quote-api.jup.ag/v6/quote"
f"?inputMint=So11111111111111111111111111111111111111112"
f"&outputMint={token_addr}"
f"&amount={lamports_in}"
"&slippageBps=50"
)
quote_resp = requests.get(quote_url, timeout=10).json()
if "routePlan" not in quote_resp or not quote_resp["routePlan"]:
print(f"[WARN] No routePlan for {token_addr}")
return None

# 2) Construct the swap request
swap_req = {
"quoteResponse": quote_resp, # Pass the entire quote here
"userPublicKey": str(WALLET_PUBKEY),
"destinationWallet": str(WALLET_PUBKEY), # optional, can be same as userPublicKey
"wrapAndUnwrapSol": True
}

swap_url = "https://quote-api.jup.ag/v6/swap"
swap_resp = requests.post(swap_url, json=swap_req, timeout=10).json()
if "swapTransaction" not in swap_resp:
print(f"[ERROR] No 'swapTransaction' in Jupiter swap response: {swap_resp}")
return None

tx = # ???

send_resp = client.send_transaction(tx)
signature = send_resp["result"]
print(f"[BUY] {token_addr}, signature={signature}")
return signature


Подробнее здесь: https://stackoverflow.com/questions/793 ... transation

Вернуться в «Python»