-
Notifications
You must be signed in to change notification settings - Fork 255
Contract Trade
[TOC]
In the following query of the relevant interface, the sell order returned is in one format, as well as buy order. Format is listed only in the first sell order or buy order query. sell orderbuy order status status 1, TradeOrderStatusOnSale, for sale status 2: TradeOrderStatusSoldOut, sold out status 3: TradeOrderStatusRevoked, sell order withdrawn status 4: TradeOrderStatusExpired,order timeout (not supported currently) status 5: TradeOrderStatusOnBuy, on buy status 6: TradeOrderStatusBoughtOut, bought out status 7: TradeOrderStatusBuyRevoked,buy order withdrawn
Address specified only Specify both address and token
request: http.post
{
"jsonrpc":"2.0",
"id" : 1 ,
"method" : "Chain33.Query",
"params":[{
"execer" : "trade",
"funcName" : "GetOnesBuyOrder",
"payload" : {
"addr" : "string"
}
}]
}
Or
{
"jsonrpc":"2.0",
"id" : 1 ,
"method" : "Chain33.Query",
"params":[{
"execer" : "trade",
"funcName" : "GetOnesBuyOrder",
"payload" : {
"addr" : "string",
"token": [ "string", "string"]
}
}]
}
method: Chain33.Query execer: trade funcName: GetOnesBuyOrder addr:buy order holder token: identifier of specific token, which can be more than one
response:
{
"id":int32,
"error":null,
"result": {
"buyOrders" : [{
"buyID" : "string",
"sellID" : "string",
"txHash" : "string",
"key" : "string",
"height" : int64,
"tokenSymbol" : "string",
"status" : int32,
"owner" : "string",
"blockTime" : int64,
"isSellOrder" : bool,
"tradedBoardlot" : int64,
"pricePerBoardlot" : int64,
"amountPerBoardlot" : int64,
"minBoardlot" : int64,
"totalBoardlot" : int64
}
]}
}
result: list corresponding to the buy order key: it could be buyID or txHash. In the current sell order, it is txHash, while in the limit buy order, it is buyID. txHash: hash corresponding to the transaction tokenSymbol: token identifier owner: tokensell order address blockTime: UTC time of block generated isSellOrder: whether it is buy order status: buy order status height: height of the block where buy order is amountPerBoardlot: amount per board lot minBoardlot: minimum board lot pricePerBoardlot: price per board lot totalBoardlot: total lot size of board tradedBoardlot: traded board lot
request: http.post
{
"jsonrpc":"2.0",
"id" : 1 ,
"method" : "Chain33.Query",
"params":[{
"execer" : "trade",
"funcName" : "GetOnesBuyOrderWithStatus",
"payload" : {
"addr" : "string",
"status" : int32
}
}]
}
method: Chain33.Query execer: trade funcName: GetOnesBuyOrderWithStatus addr: status: buy order status
response:
{
"id":int32,
"error":null,
"result": {
"buyOrders" :[{
"buyID" : "string",
"sellID" : "string",
"txHash" : "string",
"key" : "string",
"height" : int64,
"tokenSymbol" : "string",
"status" : int32,
"owner" : "string",
"blockTime" : int64,
"isSellOrder" : bool,
"tradedBoardlot" : int64,
"pricePerBoardlot" : int64,
"amountPerBoardlot" : int64,
"minBoardlot" : int64,
"totalBoardlot" : int64
}
]}
}
result: lists corresponding to buy order all items are same as ### 1.1
request: http.post
{
"jsonrpc":"2.0",
"id":int32,
"method":"Chain33.Query",
"params":[{"execer" : "trade",
"funcName" : "GetTokenBuyOrderByStatus",
"payload" : {"tokenSymbol": string, status: int32, "count":string, "direction": int32, "fromKey" : string}
}]
}
method: Chain33.Query execer: trade funcName: GetTokenBuyOrderByStatus status: order status (default is 4, purchasing status) count:sell order amount direction: 0 previous page; 1 next page tokenSymbol: fill in the token identifier fromKey: buy order key Don't fill in the first page. To get the next page, fill in the key of the last buy order on the page. To get the previous page, fill in the key for the first buy order on this page.
response:
{
"id":int32,
"error":null,
"result":{
"buyOrders" : [{
"buyID" : "string",
"sellID" : "string",
"txHash" : "string",
"key" : "string",
"height" : int64,
"tokenSymbol" : "string",
"status" : int32,
"owner" : "string",
"blockTime" : int64,
"isSellOrder" : bool,
"boughtBoardlot" : int64,
"pricePerBoardlot" : int64,
"amountPerBoardlot" : int64,
"minBoardlot" : int64,
"totalBoardlot" : int64
}
]}
}
result: corresponds to the list of buy order. Same as 1.1
request: http.post
{
"jsonrpc":"2.0",
"id":int32,
"method":"Chain33.Query",
"params":[{"execer" : "trade",
"funcName" : "GetOnesSellOrder",
"payload" : {"addr": string, "token": ["string", "string"]}
}]
}
method: Chain33.Query execer: token funcName: GetOnesSellOrder addr:sell order holder token: identifiers for specific tokens, which can be multiple or not specified
response:
{
"id":int32,
"error":null,
"result": {
"sellOrders" :[{
"buyID" : "string",
"sellID" : "string",
"txHash" : "string",
"key" : "string",
"height" : int64,
"tokenSymbol" : "string",
"status" : int32,
"owner" : "string",
"blockTime" : int64,
"isSellOrder" : bool,
"tradedBoardlot" : int64,
"pricePerBoardlot" : int64,
"amountPerBoardlot" : int64,
"minBoardlot" : int64,
"totalBoardlot" : int64
}
]}
}
result: list corresponding to sell order key: it could be sellID or txHash. In the current sell order, it is txHash, while in the limit sell order, it is sellID. txHash: hash corresponding to the transaction sellID: sell orderid buyID: buy orderid tokenSymbol: token identifier owner: tokensell order address blockTime: UTC time of block generated isSellOrder: whether it is buy order status: sell order status height: height of the block where sell order is amountPerBoardlot: amount per board lot minBoardlot: minimum board lot pricePerBoardlot: price per board lot totalBoardlot: total lot size of board tradedBoardlot: traded board lot tokensymbol: token on sale identifier
request: http.post
{
"jsonrpc":"2.0",
"id":int32,
"method":"Chain33.Query",
"params":[{"execer" : "trade",
"funcName" : "GetAllSellOrderWithStatus",
"payload" : {"addr": string, "status": int32}
}]
}
method: Chain33.Query execer: trade funcName: GetAllSellOrderWithStatus addr:sell order address status: 1 stands for selling status; 2 status of sold out; 3 sell order is revoked status
response:
{
"id":int32,
"error":null,
"result":{
"sellOrders" : [{
"buyID" : "string",
"sellID" : "string",
"txHash" : "string",
"key" : "string",
"height" : int64,
"tokenSymbol" : "string",
"status" : int32,
"owner" : "string",
"blockTime" : int64,
"isSellOrder" : bool,
"tradedBoardlot" : int64,
"pricePerBoardlot" : int64,
"amountPerBoardlot" : int64,
"minBoardlot" : int64,
"totalBoardlot" : int64
}
]}
}
result: List corresponding to sell order. Same as 1.4
See 1.1
See 1.1
request: http.post
{
"jsonrpc":"2.0",
"id":int32,
"method":"Chain33.Query",
"params":[{"execer" : "trade",
"funcName" : "GetTokenSellOrderByStatus",
"payload" : {"tokenSymbol": string, status: int32, "count":string, "direction": int32, "fromKey" : string}
}]
}
method: Chain33.Query execer: trade funcName: GetTokenSellOrderByStatus status: query status (default 1, on sale) count:sell order count direction: 0 previous page 1 next page tokenSymbol: fill in the token identifier fromKey: sell order key Don't fill in the first page. To get the next page, fill in the key of the last buy order on the page. To get the previous page, fill in the key for the first buy order on this page.
response:
{
"id":int32,
"error":null,
"result":{
"sellOrders" : [{
"buyID" : "string",
"sellID" : "string",
"txHash" : "string",
"key" : "string",
"height" : int64,
"tokenSymbol" : "string",
"status" : int32,
"owner" : "string",
"blockTime" : int64,
"isSellOrder" : bool,
"tradedBoardlot" : int64,
"pricePerBoardlot" : int64,
"amountPerBoardlot" : int64,
"minBoardlot" : int64,
"totalBoardlot" : int64
}
]}
}
result: List corresponding to sell order. Same as 1.4
request: http.post
{
"jsonrpc":"2.0",
"id":int32,
// "method":"Chain33.CreateRawTradeSellTx",
"method":"trade.CreateRawTradeSellTx",
"params":[
{
"tokenSymbol":"string",
"amountPerBoardlot":int64,
"minBoardlot":int64,
"pricePerBoardlot":int64,
"totalBoardlot":int64,
"fee" : int64
}
]
}
method: Chain33.CreateRawTradeSellTx。 tokenSymbol: token identifier amountPerBoardlot: amount per board lot minBoardlot: minimum board lot pricePerBoardlot: price per board lot totalBoardlot: total lot size of board fee: transaction fee
response:
{
"id":int32,
"error":null,
"result": "string"
}
result: hexadecimal transaction encoded strings
request: http.post
{
"jsonrpc":"2.0",
"id":int32,
// "method":"Chain33.CreateRawTradeBuyTx",
"method":"tradeCreateRawTradeBuyTx",
"params":[
{"sellID":string,
"boardlotCnt":int64,
"fee" : int64
}
]
}
sellID: sell orderid boardlotCnt: board lot, unit is hand. fee: transaction fee
response:
{
"id":int32,
"error":null,
"result": "string"
}
result: hexadecimal transaction encoded strings
request: http.post
{
"jsonrpc":"2.0",
"id":int32,
// "method":"Chain33.CreateRawTradeRevokeTx",
"method":"trade.CreateRawTradeRevokeTx",
"params":[{
sellID":"string",
"fee" : int64
}]
}
sellID: sell orderid fee: transaction fee
response:
{
"id":int32,
"error":null,
"result": "string"
}
result: hexadecimal transaction encoded strings
request: http.post
{
"jsonrpc":"2.0",
"id":int32,
// "method":"Chain33.CreateRawTradeBuyLimitTx",
"method":"trade.CreateRawTradeBuyLimitTx",
"params":[
{
"tokenSymbol":"string",
"amountPerBoardlot":int64,
"minBoardlot":int64,
"pricePerBoardlot":int64,
"totalBoardlot":int64,
"fee" : int64
}
]
}
method: Chain33.CreateRawTradeBuyLimitTx。 tokenSymbol: token identifier amountPerBoardlot: amount per board lot minBoardlot: minimum board lot pricePerBoardlot: price per board lot totalBoardlot: total lot size of board fee: transaction fee
response:
{
"id":int32,
"error":null,
"result": "string"
}
result: hexadecimal transaction encoded strings
request: http.post
{
"jsonrpc":"2.0",
"id":int32,
// "method":"Chain33.CreateRawTradeSellMarketTx",
"method":"trade.CreateRawTradeSellMarketTx",
"method":
"params":[
{"buyID":string,
"boardlotCnt":int64,
"fee" : int64
}
]
}
buyID: buy orderid boardlotCnt: purchase quantity, unit is hand fee: transaction fee
response:
{
"id":int32,
"error":null,
"result": "string"
}
result: hexadecimal transaction encoded strings
request: http.post
{
"jsonrpc":"2.0",
"id":int32,
// "method":"Chain33.CreateRawTradeRevokeBuyTx",
"method":"trade.CreateRawTradeRevokeBuyTx",
"params":[{
"buyID":"string",
"fee" : int64
}]
}
buyID: buy orderid fee: transaction fee
response:
{
"id":int32,
"error":null,
"result": "string"
}
result: hexadecimal encoded transaction strings
request: http.post
{
"id" : 1 ,
"method" : "Chain33.Query",
"params":[{
"execer" : "trade",
"funcName" : "GetOnesOrderWithStatus",
"payload" : {
"status" : 1,
"addr" : "1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK",
"direction": 1,
"count" : 10,
"fromKey" : ""
}
}]
}
status: 1: uncompleted transaction, 2: completed transaction, 3: withdrawn transaction addr: specified direction: 0, in descending order of height, 1, in ascending order of height count: count number fromKey: no specify on the first page. For other pages, specify the last key on the previous page
response:
{
"id" : 1,
"error" : null,
"result" : {
"orders" : [
{
"txHash" : "0xe58a6917a504d32bb0303a2dad7c0bcb4558a66b7d8959d857196074886eeaf5",
"sellID" : "mavl-trade-sell-e58a6917a504d32bb0303a2dad7c0bcb4558a66b7d8959d857196074886eeaf5",
"buyID" : "",
"isSellOrder" : true,
"key" : "0xe58a6917a504d32bb0303a2dad7c0bcb4558a66b7d8959d857196074886eeaf5",
"pricePerBoardlot" : 100000000,
"totalBoardlot" : 1,
"blockTime" : 1523435542,
"status" : 1,
"height" : 189829,
"tokenSymbol" : "LJ",
"owner" : "1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK",
"tradedBoardlot" : 0,
"minBoardlot" : 1,
"amountPerBoardlot" : 100000000
}
]
}
}
hello world