You are viewing a single comment's thread:
Ecco, ora dovrebbe andare.
Mancava "type": "custom_json_operation",
quando veniva creato il custom_json.
from beem import Hive
from beem.account import Account
from beembase.operations import Custom_json
import json
# Dati utente
username = "xxxx"
active_key = "xxxxx" # tua chiave privata
# Inizializza blockchain
hive = Hive(keys=[active_key])
account = Account(username, blockchain_instance=hive)
# Parametri ordine
quantity = "1.00000"
price = "1"
symbol = "SWAP.HIVE" # Hive su Hive-Engine
order_type = "sell"
json_data = {
"contractName": "market",
"contractAction": order_type,
"contractPayload": {
"symbol": symbol,
"quantity": quantity,
"price": price
}
}
# Prepara e firma la transazione JSON
tx = Custom_json(
**{
"type": "custom_json_operation", # <--- mancava questo
"required_auths": [username],
"required_posting_auths": [],
"id": "ssc-mainnet-hive",
"json": json.dumps(json_data)
}
)
# Invia la transazione
broadcast_result = hive.finalizeOp(tx, username, "active")
print("Ordine piazzato:")
print(broadcast_result)
Ho fatto due test con un altro token (perchè non avevo SWAP.HIVE a disposizione) e mi ha creato gli ordini :)
grazie mille! Ho riprovato con la correzione, ma non capisco come capire se l'ordine è andato a buon fine...
View more