Home > Blockchain >  Article 37 application chain contract deployment
Article 37 application chain contract deployment

Time:09-22

Nuwa v1.0.8, introduced the concept of contract more sub chain, substring more contracts refers to the deployment of multiple intelligence in a sliver chain contracts, contracts can be more take apart the business logic, call each other, the contract between can also upgrade,

In this paper, the test environment: 64 - bit Windows 10 Chinese version. The version number: 1.0.8; Network: testnet;



1. The sub chain structures,

The following in accordance with the "article 6 block chain locations (MOAC BlockChain) substring build tutorial" steps, use version 1.0.8 build a substring,

Deployment substring mineral pool SubChainProtocolBase. Sol;
Deployment of three SCS, and register to the substring pool;
Deployment Vnode mineral pool VnodeProtocolBase. Sol and native Vnode node registered with the pool;
Deploy erc20 contract erc20. Sol;
Deployment of sub chain contract SubChainBase. Sol;
Please note here, deployment SubChainBase. Sol, to participate in substring SCS number and refresh cycle requirements, so stipulated in contract:

//qualification here
The function SubChainBase (address proto, address vnodeProtocolBaseAddr, address ercAddr, uint ercRate, uint min, uint Max, uint thousandth, uint flushRound) public {
Require (min 1==| | min==| 3 | min==5 | | min==7).//minimum number of SCS
Require (Max==11 | | Max==21 | | Max==31 | | Max==51 | | Max==99).//maximum number of SCS, and minimum quantity corresponds to the
Require (flushRound & gt;=40 & amp; & FlushRound & lt;=500);//refresh cycle
In this paper, the experimental actual deployment SubChainBase. The parameters of the sol is as follows:



Deployment of SCS start out of the blocks, join the SCS monitor and synchronized to the latest, substring that is deployed success:





2. The deployment of underlying business

DAPP intelligent contract also sent by the main chain sendTransaction traded to proxy vnode way to deploy,

Parameters:

To: substring control contract subchainbase address
Gas: no need to consume gas fees, transfer value: 0
Shardingflag: substring operation, the value: 0 x3, please note that the contract version deploy any contract shardingflag 0 x3
Via: corresponding proxy vnode returns address
Deployment of more basic agreement in child chain dappbase. Sol, deployment example:

Chain3=the require (' chain3 ')
Solc=the require (' solc)
Chain3=new chain3 ();
Chain3. SetProvider (new chain3. Will. HttpProvider (' http://localhost:8545 '));
Solfile='deorder. Sol;
Contract=fs. ReadFileSync (solfile, 'utf8);
The output=solc.com running (contract, 1);
Abi=output. Contracts [' : DeOrder ']. Interface;
Bin=output. Contracts [' : DeOrder ']. The bytecode.
Subchainaddr='0 x1195cd9769692a69220312e95192e0dcb6a4ec09';
Via='0 xf103bc1c054babcecd13e7ac1cf34f029647b08c';
Chain3. Personal. UnlockAccount (chain3. MC. Accounts [0], '123456');
Chain3. MC. SendTransaction ({the from: chain3. MC. Accounts [0], value: 0, to: subchainaddr, gas: 0, shardingFlag: "0 x3," data: '0 x + bin, the nonce: 0, via: via,});
This article USES the wallet tool deployment: http://wallet.moac.io/deploy-contract

Validation:

Contracts after the success of the deployment, Nonce value should be 1, can be called the monitor of the RPC interface ScsRPCMethod. Check GetNonce,



The main resources:

1. https://moacdocs-chn.readthedocs.io/zh_CN/latest/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Copyright statement: in this paper, the author (Li_Yu_Qing)

CodePudding user response:

  • Related