5 A simple deposit and profit bytom dapp demo, Bytom-Chrome-Extension needed before it can be used.
8 - Install [Node.js](https://nodejs.org) version 8 and the latest available npm@6.
9 - Install dependencies: `npm install`.
12 Before run all the project, you may need to set up you own [bufferserver](https://github.com/oysheng/bufferserver). Configure the proxy rules under the `webpack.config.js`.
15 Currently we are manually deploy the contract using the [equity compiler tool](https://github.com/Bytom/equity), and configure the `control program` constants accordingly.
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.
22 Under the `./src/components/util/submitContract.js`, you will see the basic and reusable logic, for developing a Dapp. Including the following steps:
23 - list utxo from buffer server
24 - create the custom contract transaction
26 - call `window.bytom.send_advanced_transaction` to create the advanced Transaction
27 - update balance if success.
29 ### Input and Output Object
31 The first Input object must be spend utxo action, utxo will be selected according to the amount matches.
33 The second Spend Wallet Action, maybe needed if there is a exchanged.
36 input.push(spendUTXOAction(utxo))
37 input.push(spendWalletAction(amount, GetContractArgs().assetDeposited))
41 Since the contract type and logic are different, building the unlock action may be different.
44 if amountDeposited < billAmount {
45 lock amountDeposited of assetDeposited with FixedLimitProfit(billAsset, totalAmountBill, totalAmountCapital, expireBlockHeight, additionalBlockHeight, banker, bankerKey)
46 lock amountDeposited of billAsset with saver
47 lock billAmount-amountDeposited of billAsset with FixedLimitCollect(assetDeposited, totalAmountBill, totalAmountCapital, dueBlockHeight, expireBlockHeight, additionalBlockHeight, banker, bankerKey)
49 lock amountDeposited of assetDeposited with FixedLimitProfit(billAsset, totalAmountBill, totalAmountCapital, expireBlockHeight, additionalBlockHeight, banker, bankerKey)
50 lock billAmount of billAsset with saver
53 Will need to be converted into
55 if(amount < billAmount){
56 output.push(controlProgramAction(amount, GetContractArgs().assetDeposited, GetContractArgs().profitProgram))
57 output.push(controlAddressAction(amount, billAsset, address))
58 output.push(controlProgramAction((BigNumber(billAmount).minus(BigNumber(amount))).toNumber(), billAsset, GetContractArgs().depositProgram))
60 output.push(controlProgramAction(amount, GetContractArgs().assetDeposited, GetContractArgs().profitProgram))
61 output.push(controlAddressAction(billAmount, billAsset, address))
68 Make sure the contracts are compiled, built the correct input output object and bufferserver is running.
70 Start the Webpack dev server.
74 Your server should now be running at http://127.0.0.1:8080
76 ## Building the Project