Home > Blockchain >  Article 6 hair chain stone blocks a key chain chain (application) (2) build tutorial
Article 6 hair chain stone blocks a key chain chain (application) (2) build tutorial

Time:09-23

A key chain three levels, this paper is the official script first level, the second level is to perfect the
1, the official script
Needless to say, from the official documents, and provide the AST, advance the ASM script, with simple input, can build a good chain
2, an automated build script
Problem with SCS books need to be synchronized, maybe need two days, this improved method derived from existing on the SCS books, imported into the new SCS node, synchronization time will be shorten, users can set up his application as soon as possible chain
3, establish
Official team registered good SCS first, the user to use directly, equivalent to his fine decoration rough
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Beijing time on June 30, 2018, MOAC application chain is launched open beta,
Beijing time on July 12, 2019, MOAC Nuwa1.0.10, this version is suitable for the main (mainnet) and test (testnet),

Following are MOAC testnet chain installation and application tutorial, mainnet application chain construction process is the same (MOAC oh to pay money),

6.4 open registration application chain

Registration application through an open chain, SCS internal candidates to complete the registration, eventually become a member of the application of chain, are eligible to participate in the application of chain related business, it is important to note: SCS to participate in the application of chain is registered by SCS address (we also called scsid, under the "./scskeystore "directory) send deals to the application of chain is complete; So you need to reserve a certain amount of moac SCS address, suggested a moac, at the same time, application of chain contracts need to eventually offer SCS gas fee, therefore, also need to send application chain control contract a certain amount of moac,

Please note: the sending application chain control contract moac, cannot send directly, need to use the function in the contract addFund (),



Deploy the chain open registration code below registerOpen. Js, execution node can,

Var Chain3=the require (' Chain3 ');
Var chain3=new chain3 (new chain3. Will. HttpProvider (' http://localhost:8545 '));
//register open
Var dappAddr="0 x7610fd66c272332edd59a43460ad24eee1973bfe";
Var dappPasswd="password";
Var subchainAddr="0 x8a194e9567d7339b968dac61546a52f89a8c7a2f";//application chain control address

Chain3. Personal. UnlockAccount (dappAddr, dappPasswd, 0);
Sendtx (dappAddr subchainAddr, '0', '0 x5defc56c');

The function sendtx (SRC, tgtaddr, amount, strData) {
Chain3. MC. SendTransaction (
{
From: SRC,
Value: chain3. ToSha (amount, 'MC'),
To: tgtaddr,
Gas: "2000000",
GasPrice: chain3. MC. GasPrice,
Data: strData
});
The console. The log (' sending the from: '+ SRC +', '+ tgtaddr +' with data: '+ strData);
}
DappAddr dappPasswd: Dapp user account unlock before trading was used to send;
Subchainbase subchainAddr: deploy your chain control contracts address;
Data: '0 x5defc56c' is the application of chain control agreement in subchainbase 'registerOpen ()' by Keccak256 of hash algorithm is the first 4 bytes, here don't have to change;
This step also can not use the code, but at http://wallet.moac.io contract function complete,



6.5 checking their registration

After through registerOpen, the system will automatically select eligible SCS node and inform them to register, DAPP user needs to be done through the following method to view has registered the SCS node number (nodeCount) :

MC. GetStorageAt (subchainAddr, 0 x0e)


In contract by contract address subchainAddr queries x0e 0 a public member variables (i.e., nodeCount) value, please do not modify the value when the number of the SCS required for application of chain operation range, can enter the RegisterClose steps,

This step can also be on the http://wallet.moac.io direct function to check the contract, also can query the registered id of SCS,


6.6 application chain close registration

First introduce RegisterClose main job:

Dapp registered users to set up the chain closed;
Have registered SCS number must not be less than the minimum number of application chain requirements, otherwise the application chain registration is invalid;
Main radio call the candidate SCS agreement contract, including registered successful SCS;
SCS receive radio SCS itself, the initialization and start application of chain operation,
Close the chain after registration, the candidate SCS can't through the subchain chain RegisterOpen way to register the application, has registered the normal operation of the SCS, participate in the application of chain related business, such as: processing trade, out of the blocks, refresh, etc.,

Deploy the chain close registration code below registerClose. Js, execution node can,

Var Chain3=the require (' Chain3 ');
Var chain3=new chain3 (new chain3. Will. HttpProvider (' http://localhost:8545 '));
//register open
Var dappAddr="0 x7610fd66c272332edd59a43460ad24eee1973bfe";
Var dappPasswd="password";
Var subchainAddr="0 x8a194e9567d7339b968dac61546a52f89a8c7a2f";//application chain control address

Chain3. Personal. UnlockAccount (dappAddr, dappPasswd, 0);
Sendtx (dappAddr subchainAddr, '0', '0 x69f3576f');

The function sendtx (SRC, tgtaddr, amount, strData) {
Chain3. MC. SendTransaction (
{
From: SRC,
Value: chain3. ToSha (amount, 'MC'),
To: tgtaddr,
Gas: "2000000",
GasPrice: chain3. MC. GasPrice,
Data: strData
});
The console. The log (' sending the from: '+ SRC +', '+ tgtaddr +' with data: '+ strData);
}
Among them,

DappAddr dappPasswd: Dapp user account unlock before trading was used to send;
SubchainAddr: deploy your chain contracts get contracts address;
Data: '0 x69f3576f' is the application of chain control agreement in subchainbase 'registerClose ()' by Keccak256 of hash algorithm is the first 4 bytes.
Completed, if all goes well, application and began to a piece of the completion of chain,

This step also can not use the code, but at http://wallet.moac.io contract function complete,



The measured environment three SCS take turns out, according to the following,



Figure shows the SCS piece of normal, the current application for chain blocks, 15 by the SCS dig out successful,

If is the application of synchronous other SCS chain blocks, "SendBkToVnode" is shown as "Insert", namely synchronous other SCS blocks,



At this point, deployed application chain,



7. SCS monitor

Monitor is a special SCS node, it is a kind of mode, DAPP users can through the nodes to Monitor their own application of chain operation and business data,

SCS Monitor does not participate in the application of chain consensus, so can only see, can't modify the data, even if the application of chain has been running, the Monitor can also register to join,

Monitor for SCS startup mode (needs its own password, plus the -p "password") :

D: \ nuwa1.0.10. Win, win, scs> Scsserver - RPC rpcaddr 0.0.0.0-2345 - rpcport rpccorsdomain "*" -- verbosity 4
Starts, DAPP user applications by calling the chain control contract subchainbase registerAsMonitor method makes the Monitor in the SCS chain synchronous data access applications,

Deploy the chain open registration code below registerAsMonitor. Js, execution node can,

Var Chain3=the require (' Chain3 ');
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related