1
preface
[Project Objective]
To develop a disintermediated EOS DAPP for rental, so as to achieve mutual win between renters and landlords.
[Project requirements]
1. Establish local node, create wallet, load biod contract, and create token allocation account.
2. Deploy eOSJS project, provide APIS for creating token contracts, creating accounts (batch), transferring funds, checking token balances, etc.
3, a WEB front end to a simple interface that rent a house, can browse the rental information, member after the registration (free tokens), can make an appointment to see, can see the house of housing (tokens), who has scored the housing rent after can (tokens), the background the landlord can publish rental housing (tokens), flip houses state (tokens), tokens after platform for value-added, Can be used as rent payment or mortgage.
4. The token name of this project is: BLR (short for BlockRent)
[Test environment]
Ubuntu18.04, docker18.03.1-ce, EOS DAWN v1.0.8 were installed in Windows 10.
2
Deploying a Local Node
1. Start the node
$ sudo docker run --rm--name eosio -d -p 8888:8888 -p 9876:9876 -v /tmp/work:/work -v/tmp/eosio/data:/mnt/dev/data -v /tmp/eosio/config:/mnt/dev/configeosio/eos-dev /bin/bash -c "nodeos-e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::wallet_plugin--plugin eosio::producer_plugin --plugin eosio::history_plugin --plugineosio::chain_api_plugin --plugin eosio::history_api_plugin --plugineosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config--http-server-address=0.0.0.0:8888 --access-control-allow-origin=*--contracts-console"
$ docker exec -it eosio/bin/bash
Copy the code
2. Search for the EOSIO public and private keys
Ini file and search for signature-provider to find the eoSIO public/private key.
EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
Copy the code
Note: In DAWNv1.0.2, the private key can be created independently of the wallet account operation, but after V1.0.5, the private key must be imported into the wallet to operate, so we copied the public key early to prepare for the next operation.
3. Create a wallet
cleos wallet create -nblockrent_wallet
PW5KPFSWL3YfgRPVaER9EjoScBk1Afdcx6T3RVWHCqpjfuuySmC7G
Copy the code
4. Import the EOSIO account key into the wallet
cleos wallet import -nblockrent_wallet 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
Copy the code
5. Create a BIOS contract
cleos set contract eosiocontracts/eosio.bios -p eosio
# return the transaction address
cd15f3ee17c043f202f801444e73b69165d0becd6d153ad8e41c870e88421a87
Copy the code
6. Create a KEY
Create contract account blockrent111
cleos create key
Private key:5JhDyR6zNDifzoJPE5MnfxvLvbHdXTSBuKzaXEr82rL6ChoRyvL
Public key:EOS5JPDqzVDQ8kCo6AWdxhKpynmJsWUfbwBiaDs2fMNhAnEDSd525
# Team and Foundation Blockrent222
cleos create key
Private key:5KQYJzZAR8CgrLW3x7vkhm86NKxziDoZn2JJKhdbTbH9WjTdGZ8
Public key: EOS6t22TsDrrSnmkDv2pv4jagZMxnw4Hc8pQcmTo8476inymwqn9d
# Community cultivation and promotion of Blockrent333
cleos create key
Private key:5JKqGKqPkCtQc8EHy5paZ9KJKnRKY4XEukWtVn1w7HT9ZHZGip5
Public key:EOS5qGrpjdFR647sbec1sQyqvnQ8hrUZJGR1t24EGue1HUJKWLEes
# Incentive pool blockrent444
cleos create key
Private key:5JQ85e4AMagc3D43dvH6ngFG6ak6ubVamweMhHcTxBjKTfSWGXP
Public key:EOS63yTyuJnbgoCVDXkrgjG9SGCSxBLUAYscZWQf4NaLV7oTkM2ex
# Targeted invitation agency Blockrent555
cleos create key
Private key:5JmQQpEGgXBD33g1yy4bFfaPfsQZrwqU9UwUKwphC1hZ5WqBsXL
Public key: EOS7X9EPbQdGxUMfN7bXTQz1cUSWxwpGjTPt8yGsiFxuDfFAWkhS8
Copy the code
7. Import KEY to wallet
cleos wallet import -nblockrent_wallet 5KQYJzZAR8CgrLW3x7vkhm86NKxziDoZn2JJKhdbTbH9WjTdGZ8
cleos wallet import -nblockrent_wallet 5JKqGKqPkCtQc8EHy5paZ9KJKnRKY4XEukWtVn1w7HT9ZHZGip5
cleos wallet import -nblockrent_wallet 5JQ85e4AMagc3D43dvH6ngFG6ak6ubVamweMhHcTxBjKTfSWGXP
cleos wallet import -nblockrent_wallet 5JmQQpEGgXBD33g1yy4bFfaPfsQZrwqU9UwUKwphC1hZ5WqBsXL
Copy the code
8. Create an account
cleos create account eosioblockrent111 EOS5JPDqzVDQ8kCo6AWdxhKpynmJsWUfbwBiaDs2fMNhAnEDSd525 # EOS mortgage required
cleos create accountblockrent111 blockrent222 EOS6t22TsDrrSnmkDv2pv4jagZMxnw4Hc8pQcmTo8476inymwqn9d
cleos create accountblockrent111 blockrent333 EOS5qGrpjdFR647sbec1sQyqvnQ8hrUZJGR1t24EGue1HUJKWLEes
cleos create accountblockrent111 blockrent444 EOS63yTyuJnbgoCVDXkrgjG9SGCSxBLUAYscZWQf4NaLV7oTkM2ex
cleos create accountblockrent111 blockrent555 EOS7X9EPbQdGxUMfN7bXTQz1cUSWxwpGjTPt8yGsiFxuDfFAWkhS8
Copy the code
We can view the account details by using cleosget account < account name > -j, where the -j parameter indicates the output in JSON format.
9. Create a token contract BLR
cleos set contractblockrent111 contracts/eosio.token/ -p blockrent111
# cleos push actionBlockrent111 create '["eosio", "1000000000.0000 BLR", 0,0]' -p blockrent111
cleos push actionblockrent111 create ["blockrent111", "1000000000.0000BLR", 0, 0, 0] -p blockrent111
Copy the code
10. Issue tokens
At the product design stage, we agreed on the incentive distribution as follows:
· Team and Foundation (Blockrent222) 25%=250000000.0000 BLR · Community Cultivation and Promotion (Blockrent333) 15%=150000000.0000 BLR · Incentive pool (Blockrent444) 40%=400000000.0000 BLR · Targeted invitation institution (Blockrent555) 20%=200000000.0000 BLR CLEos push ActionBlockrent111 issue'["blockrent222", "250000000.0000 BLR"," issue 25% to Blockrent222 "]' -pblockrent111
cleos push actionblockrent111 issue '[" Blockrent333 "," 150000000.0000 BLR"," Issue 15% to Blockrent333 "]' -pblockrent111
cleos push actionblockrent111 issue '["blockrent444", "400000000.0000 BLR"," issue 40% to Blockrent444 "]' -pblockrent111
cleos push actionblockrent111 issue '[" Blockrent555 "," 200000000.0000 BLR"," Issue 20% to Blockrent555 "]' -pblockrent111
Copy the code
So far, we have established a local private blockchain, created a token contract BLR, and issued it to 4 sub-accounts according to incentive allocation rules. In the next development, we will use the balance of incentive pool Blockrent444 to trade.
3
Deploy EOSJS API
1. Clone eOSJS project code
Here the project code is deployed on the Ubuntu system running the local node. If it is in a production environment, the project can be deployed separately with a separate IP accessible externally.
cd ~/
git cloneVisit http://localhost:8888/v1/chain/get_info https://github.com/luoxiaohui/eos4node.git for local node information, localhost can also change the LAN IP address, Copy the chain_id field value. Find the ~ / eos4node/app/controller/home. The js file, depending on the local node data, make the following changes: 13 lines const pk ='* * *'Is changed to blockrent444 account private key. Const eosServer = at line 20'* * *'Comment out and enable the local service address on line 22. Const mainAccount = at line 28'* * *'Change this parameter to blockrent444. Line 45 const eos = eos (...) ; , including chainId modified to chain_id field values, such as cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f. 295 lines myaccount. Create... , can modify the token name and total issue. Save and upload.Copy the code
2. Run the project and start the service
cd ~/eos4node
Node_modules will take some time to download$NPM I $NPM run dev > [email protected] dev/home/simon/eos4node > egg-bin dev 2018-07-09 17:45:36,209INFO 24999 [master] 2018-07-09 17:45:36,211INFO 24999 [master] Egg version 2.9.1 2018-07-09 17:45:36,664INFO 24999 [master] agent_worker#1:25005 started (450ms)
2018-07-09 17:45:37,580INFO 24999 [master] egg started on http://127.0.0.1:7001 (1369ms)
Copy the code
As shown above, our server-side API is ready.
4
The front-end docking
For brevity, we have omitted the interface. We can open a new terminal to simulate the front-end access API, or download a Chrome plugin postman to access it.
Create the account API
Create a temporary new KEY:
cleos create key
Private key:5KbRAog4DxwAMthSrb44ZNGtGD828mzCfEvXkvVDSakxQtFBr15
Public key:EOS6y7ok9AwmToGmgsFWCQU7iGJMsStTQf6g4F6aoHTH56zEos5Sk
Copy the code
For example, create a new account, ouyangxinmin:
curl -i -X POSThttp://localhost:7001/account/create -d username=ouyangxinmin -dactive=EOS6y7ok9AwmToGmgsFWCQU7iGJMsStTQf6g4F6aoHTH56zEos5Sk -downer=EOS6y7ok9AwmToGmgsFWCQU7iGJMsStTQf6g4F6aoHTH56zEos5Sk
Copy the code
2. Transfer API
Blockrent111 transfers money to account Ouyangxinmin:
curl -i -X POSThttp://localhost:7001/transfer -d contract=blockrent111 -d from=blockrent111 -dto=ouyangxinmin -d pk=5JhDyR6zNDifzoJPE5MnfxvLvbHdXTSBuKzaXEr82rL6ChoRyvL -dquantity="1000.0000 BLR" -d mome="token reward"
Copy the code
Ouyangxinmin transfers money to account Blockrent222:
curl -i -X POSThttp://localhost:7001/transfer -d contract=blockrent111 -d from=ouyangxinmin -dto=blockrent222 -d pk=5KbRAog4DxwAMthSrb44ZNGtGD828mzCfEvXkvVDSakxQtFBr15 -dquantity="10.0000 BLR" -d mome="token reward"
Copy the code
3. The balance of the replacement currency
curl -i -X POSThttp://localhost:7001/currency/balance -d contract=blockrent111 -daccount=ouyangxinmin
5
The back-end docking
In steps 9 and 10 of section 1 above, we have deployed the contract and created the token contract through the command terminal, and can also integrate this function into the background operation. If you have already done steps 9 and 10 of Section 1, you can skip steps 1 and 2 below.
1. Call the deployment contract API
curl -i -X POSThttp://localhost:7001/deployContract -d contract=blockrent111
2. Call the interface for creating token contracts
The token name BLR has been written in the home.js code, which can be modified by referring to point 1 in Section 2, or modified as a parameter.
curl -i -X POSThttp://localhost:7001/createCurrency -d contract=blockrent111
** create test account ** in batches
curl -i -X POSThttp://localhost:7001/createCurrency -d contract=blockrent111
# return 5 accounts
"4ksalziynrzc"."jsa4pocy3rzi"."l5eauvfqmu2h"."ihl1wsbau1yr"."zaxwz2lkhkkn"."glkecjmtfnwk"
Copy the code
In order to improve user experience and allow users to create accounts without perception, some test accounts can be created in batches in the background in advance. When users register, they will be automatically bound to the registered account to achieve seamless connection with the blockchain, but this is a little too centralized, similar to the practice of exchanges.
— [Gem] Looking for development engineer —
[Job title] PHP development engineer
[Salary range] 10K-20K/Shanghai Xuhui
【 Job Description 】
1. Responsible for back-end architecture design and code writing to realize business processes;
2. Responsible for background development and docking of mobile phone side systems such as WEB APP;
[Job Requirements]
1. Proficient in PHP development, familiar with PHP development framework Thinkphp5, plus Laravel development experience;
2, Solid SQL knowledge, skilled use of MySQL database, Nosql development experience is preferred;
3. Have certain front-end programming ability, such as Jquery, Bootstrap, Vue, React and any one or two kinds of development experience
More than 2 years related development experience in Internet companies is preferred
[Job title] Front-end development engineer
[Salary range] 15K-20K/Shanghai Xuhui
【 Job Description 】
1. Responsible for the front-end construction of (PC+ mobile) interface, and various interaction design and implementation;
2. Design and develop the architecture of Web front-end presentation layer and interaction with the back-end;
3. Continuously optimize front-end experience and page response speed, and ensure compatibility and execution efficiency.
[Job Requirements]
1. At least 3 years of WEB front-end (HTML5) development experience, front-end reconstruction and script development experience;
2. Proficient in HTML5, CSS/CSS3, JavaScript and other front-end related technologies, familiar with W3C standards;
3. Familiar with VUE, React,Jquery, JqueryMobile and other frameworks, experience in responsive page development, able to develop applications compatible with mobile browsers and achieve various interactive effects;
4, Html5 WEB App packaging technology is preferred;
5. Be interested in blockchain projects, understand smart contracts, web3.js and other basic functions.
Resume address: [email protected]
Content source: Haiyang’s new (jian Shu) column
Author: Ouyang Xinmin, guest speaker of HiBlock& Shanghai Technology Workshop
Geek race, 48 hours Blockathon | block chain marathon waiting for you to challenge (chengdu)
Time: September 14-16, 2018
Venue: China-Korea Internet + New Technology Incubator, 12th Floor, Building A, No.2 Jingrong International Plaza, No.200 Tianfu 5th Street, High-tech Zone, Chengdu
-
Recruit 50 developers (to register by identifying the QR code below or clicking “Read the original article”)
-
The registration fee of 100 yuan is the deposit for the competition. There is no refund for participants who cannot attend the event due to personal reasons. Participants will participate in the whole activity and be refunded at the end of the activity. The first check-in will start at 18:00 on 14th September. Please check in every morning on 15th and 16th September.
-
The organizer provided free food and drinks for 2 days, and prepared a T-shirt for each participant
The following is our community introduction, welcome all kinds of cooperation, exchange, learning 🙂