- two sample Nep17-token contracts are placed in
CSTToken
andKFCToken
directory. - the main contract is
LoyalOrder
, which implements the order logic and all the requirements, such as user places an order or cancel order, fulfil order, are performed on chain in a decentralized way. - the web service is inplements in the
loyal-demo
directory. It mainly syncs the blocks and captures the specified logs to persist the data in the db and provides services to users to view their data.
http://localhost:8001/mint?symbol=kfc&account=0x201accefb2e195518663f735212a28ab445f57fb&amount=10000
- response:
transaction hash
.
To support users to swap tokens, the contract owner should add the corresponding token-pair on the contract first.
http://localhost:8001/addTokenPair?symbolA=stb&symbolB=kfc&ratio=1
- response:
transaction hash
.
http://localhost:8001/addOrder
- requese body:
{
"fromSymbol":"stb",
"toSymbol":"kfc",
"userAddress":"0x8d9a3212f25de2461227936882797f69906874c9",
"amount":40
}
- response:
transaction hash
.
http://localhost:8001/cancelOrder?address=0x8d9a3212f25de2461227936882797f69906874c9
- request body:
{
"fromSymbol":"kfc",
"toSymbol":"stb",
"orderId":1
}
- response:
transaction hash
.
http://localhost:8001/getOrdersByUser?address=fb575f44ab282a2135f763865195e1b2efcc1a20
- reponse body:
[
{
"orderId": 2,
"userAddress": "fb575f44ab282a2135f763865195e1b2efcc1a20",
"fromAssetAddress": "47659e005d5dffebc65f6f0a96749908dda4595a",
"toAssetAddress": "a0f39735bda53ca206342487a9d09407f8b54244",
"amount": 40,
"createTime": 1645181170481,
"txHash": null,
"fulfiledAmount": 20,
"status": 2
}
]