Introduce
Function Description
Through this program, sellers can achieve functions such as creating pending order tasks, automatically placing orders based on pending order tasks, automatically withdrawing money, automatically canceling pending orders, etc. Cross-chain is a completely decentralized point-to-point cross-chain through HASH locking contracts.
For the DST chain, if there is no full node in the local area, the full node will be started by default to provide the RPC used in the exchange. The link is http://127.0.0.1:8545 You can also configure your own RPC link
HASH lock contract process introduction
Suppose there are two chains A and B. As a seller, Tom owns the USDT assets of chain A and wants to exchange them for USDT assets of chain B. As a buyer, Alice owns the USDT assets of chain B and wants to exchange them for USDT assets of chain A.
-
Tom needs to call the creation sell order method of the HASH-locked cross-chain contract of chain A, and pass in the chain ID, selling quantity, locking time, and signature generated off-chain of chain B (the seller, according to the chain ID of chain A, The chain ID of chain B, the seller’s customized password, and the quantity signature) generate an order. The order has a unique Key (obtained from sha256(signature)), and the corresponding amount of USDT assets is transferred to the contract.
-
If Alice wants to buy, he first calls the contract method of the purchase order of the cross-chain contract locked by the A chain HASH, and confirms that he wants to buy Tom's order. At this time, the order is in a locked state.
-
Secondly, Alice needs to bring the key of the order, the chain ID of chain A, the quantity sold, the order end time, signature, and the withdrawal lock time defined by the buyer (order end time >= withdrawal lock time + current time) to call chain B How to create a sell order for a HASH-locked cross-chain contract and transfer the USDT assets of chain B into the contract
-
After Tom sees that Alice has successfully paid on chain B, he calls the method of extracting order assets of chain B and passes in the password customized by the seller when creating the order. The password will be disclosed to Alice after the transaction is successful.
-
After Alice gets the password, he needs to call the method of extracting order assets of chain A, pass in the password, and obtain the USDT assets of chain A.