These queries can be used in https://trontrade.io/graphql
You can get your TRX/TRC10/TRC20 balances from your Tron wallet like GuildWallet or TronLink.
query myOrders($address: ID!, $start: Int, $limit: Int, $status: String!, $exchangeId: Int, $sortType: String, $orderBy: String){
wallet(address: $address) {
orders(limit: $limit, start: $start, status: $status, exchangeId: $exchangeId, sortType: $sortType, orderBy: $orderBy) {
totalCount,
rows {
id
marketPrice
amount
filled
status
txStatus
createdAt
txOrder
marketId
contractId
side
completedAt
}
}
}
}
query parameters and explain:
{
"address": "TXRgUnEKA9qHwCnsmXJxvBSNogkZUGgf9v", //required. the wallet address you want to query.
"status": "0,1,2,3", //required. order status list split by comma, see `order status define ` below.
"start": 0, //optional. default 0. page index for this query, start from 0,
"limit": 50, //optional. default 50. page count for this query.
"exchangeId": 1, //optional. default null. the exchange pair id you want to filter, eg: 1 for ANTE, to get the exchange list , see ... . null for all orders.
"sortType": "createdAt", //optional. default "createdAt". the sort field you want. if you pass any invalid value, it will use the default value. note that it's case sensitive.
"orderBy": "DESC" //optional. default "DESC". if you pass any invalid value, it will use the default value. note that it's case sensitive.
}
query orderById($orderId:ID!) {
order(id: $orderId){
id
ownerWallet
side
amount
filled
marketId
marketPrice
txOrder
createdAt
completedAt
}
}
some order field explains:
side: 0 = a sell order , 1 = a buy order.
filled: the filled amout of the order.
since TronTrade is a DEX. you can place order by calling our smart contract. use tronweb.js or some other libraries or use the raw tron http/grpc api.
note that calling contract will cost your energy, make sure your calling account have enough energy, or it will charge you fees.
TRC10 contract address: TTuer45Lt3ikwF5cbJsUghQR7NW4CjJ6HS
to place a sell order call:
contract.sellToken(orderForm.getPriceValue(), TYPE_LIMIT).send({
tokenId: 1, //
tokenValue: ,
feeLimit: FEE_LIMIT,
});
** note that the call also transfer your order assets to the contract.**
to place a buy order call:
contract.buyToken(orderForm.market.tokenIdA, price, amount).send({
feeLimit: FEE_LIMIT,
callValue: orderForm.callValue(),
})
TRC20 contract address: TCgnJmYmMUJ9eS6x62Vj7YFfpBM1DTL8V8
to place a buy order call:
contract.buyToken(orderForm.market.tokenIdA, price, amount).send({
callValue: orderForm.callValue(),
feeLimit: FEE_LIMIT,
});
to place a sell order call:
// approve the contract to transfer your token when it get selled
contract.approve(orderForm.market.tokenIdA, orderForm.getTokenValue());
contract.sellToken(orderForm.market.tokenIdA, price, amount, TYPE_LIMIT).send({
feeLimit: FEE_LIMIT,
});
call the Cancel contract: TYemZc2xRyGcB831F1XstGJ1sSSW6NC6KG
cancel TRC10 order:
contract.cancelTrc10Order(orderId)
contract.cancelOrder(orderId);
query {
exchanges {
id
icon
buyAssetName
sellAssetName
tokenTypeA
tokenIdA
tokenTypeB
tokenIdB
tokenDecimalsA
tokenDecimalsB
site
listed
}
}
Failed: 0, Pending: 1, Completed: 2, Cancelled: 3,
"status", "completedAt", "createdAt", "side", "marketPrice", "amountQuantity", "filledQuantity", "total",