• R/O
  • HTTP
  • SSH
  • HTTPS

Bytom-Dapp-Demo: レポジトリ概要

A simple deposit and profit bytom dapp demo


最近のコミット RSS

Rev. 日時 作者 メッセージ
ed6b30d 2019-07-22 15:34:48 Zhiting Lin master update the account referesh balance.
ba5dd81 2019-07-22 15:17:03 Zhiting Lin update the contract argues
4f7638e 2019-07-22 14:57:36 Zhiting Lin fixed the account referesh error.
717ff8d 2019-06-26 16:25:37 Zhiting Lin update enable function.
52fa858 2019-06-12 15:54:50 Zhiting Lin update the dapp demo to fit the latest bycoin and byone
3bb6757 2019-04-02 11:21:14 Zhiting Lin update the readme file
6d938d5 2019-04-01 19:17:18 Zhiting Lin init index.js
23c4557 2019-04-01 18:41:55 Zhiting Lin init webpack.config.js
9c58c8a 2019-04-01 18:07:09 Zhiting Lin update and seperate the code in to submitContract
2d4003a 2019-03-12 16:10:02 Zhiting Lin update README.md

ブランチ

名前 Rev. 日時 作者 メッセージ
master ed6b30d 2019-07-22 15:34:48 Zhiting Lin update the account referesh...

README.md

Bytom-Dapp-Demo

What is this?

A simple deposit and profit bytom dapp demo, Bytom-Chrome-Extension needed before it can be used.

Setup

  • Install Node.js version 8 and the latest available npm@6.
  • Install dependencies: npm install.

Buffer Server

Before run all the project, you may need to set up you own bufferserver. Configure the proxy rules under the webpack.config.js.

Deploy Contract

Currently we are manually deploy the contract using the equity compiler tool, and configure the control program constants accordingly.

Contract configuration

Network and smart contract control program's constants configurations are stored under the contracts/configure.json.js file. You may edit the configure after an new control program is launched.

Dapp logic

Under the ./src/components/util/submitContract.js, you will see the basic and reusable logic, for developing a Dapp. Including the following steps: - list utxo from buffer server - create the custom contract transaction - lock utxo - call window.bytom.send_advanced_transaction to create the advanced Transaction - update balance if success.

Input and Output Object

Input

The first Input object must be spend utxo action, utxo will be selected according to the amount matches.

The second Spend Wallet Action, maybe needed if there is a exchanged.

input.push(spendUTXOAction(utxo)) input.push(spendWalletAction(amount, GetContractArgs().assetDeposited))

Output

Since the contract type and logic are different, building the unlock action may be different.

if amountDeposited < billAmount { lock amountDeposited of assetDeposited with FixedLimitProfit(billAsset, totalAmountBill, totalAmountCapital, expireBlockHeight, additionalBlockHeight, banker, bankerKey) lock amountDeposited of billAsset with saver lock billAmount-amountDeposited of billAsset with FixedLimitCollect(assetDeposited, totalAmountBill, totalAmountCapital, dueBlockHeight, expireBlockHeight, additionalBlockHeight, banker, bankerKey) } else { lock amountDeposited of assetDeposited with FixedLimitProfit(billAsset, totalAmountBill, totalAmountCapital, expireBlockHeight, additionalBlockHeight, banker, bankerKey) lock billAmount of billAsset with saver } Will need to be converted into if(amount < billAmount){ output.push(controlProgramAction(amount, GetContractArgs().assetDeposited, GetContractArgs().profitProgram)) output.push(controlAddressAction(amount, billAsset, address)) output.push(controlProgramAction((BigNumber(billAmount).minus(BigNumber(amount))).toNumber(), billAsset, GetContractArgs().depositProgram)) }else{ output.push(controlProgramAction(amount, GetContractArgs().assetDeposited, GetContractArgs().profitProgram)) output.push(controlAddressAction(billAmount, billAsset, address)) }

Run the Project

Make sure the contracts are compiled, built the correct input output object and bufferserver is running.

Start the Webpack dev server.

npm start

Your server should now be running at http://127.0.0.1:8080

Building the Project

npm run build

旧リポジトリブラウザで表示