OSDN Git Service

update README.md
[bytom/Bytom-Dapp-Demo.git] / README.md
1 # Bytom-Dapp-Demo
2
3
4 ## what is this?
5 A simple deposit and profit bytom dapp demo, Bytom-Chrome-Extension needed before it can be used. 
6
7
8 ## Setup
9 Make sure you have the NodeJs installed before you started.
10 start the webpack dev server:
11
12 ```
13 npm start
14 ```
15 Your server should now be running at http://127.0.0.1:8080 
16
17 ### Contract configuration
18 Network and smart contract control program's constants configurations are stored under the `contracts/configure.json.js` file.
19 You may edit the configure after an new control program is launched.
20
21 *Note: Currently we are manually deploy the contract using the [equity compiler tool](https://github.com/Bytom/equity), and configure the constants accordingly.
22
23 ### Input and Output Object
24 Since the contract type and logic are different, building the unlock action may be different.
25
26 ```
27 if amountDeposited < billAmount {
28       lock amountDeposited of assetDeposited with FixedLimitProfit(billAsset, totalAmountBill, totalAmountCapital, expireBlockHeight, additionalBlockHeight, banker, bankerKey)
29       lock amountDeposited of billAsset with saver
30       lock billAmount-amountDeposited of billAsset with FixedLimitCollect(assetDeposited, totalAmountBill, totalAmountCapital, dueBlockHeight, expireBlockHeight, additionalBlockHeight, banker, bankerKey)
31     } else {
32       lock amountDeposited of assetDeposited with FixedLimitProfit(billAsset, totalAmountBill, totalAmountCapital, expireBlockHeight, additionalBlockHeight, banker, bankerKey)
33       lock billAmount of billAsset with saver
34     }
35 ```
36 Will need to be converted into
37 ```
38  if(amount < billAmount){
39           output.push(controlProgramAction(amount, GetContractArgs().assetDeposited, GetContractArgs().profitProgram))
40           output.push(controlAddressAction(amount, billAsset, address))
41           output.push(controlProgramAction((BigNumber(billAmount).minus(BigNumber(amount))).toNumber(), billAsset, GetContractArgs().depositProgram))
42         }else{
43           output.push(controlProgramAction(amount, GetContractArgs().assetDeposited, GetContractArgs().profitProgram))
44           output.push(controlAddressAction(billAmount, billAsset, address))
45         }
46 ```
47
48 ## Building the Project
49    
50 `npm run build`
51