Chain block users in the deployment of intelligent contracts, if use tools, such as "stone block chain (MOAC BlockChain) deployment ERC - 20 contracts" is to use in the wallet. IO web wallet deployment of contracts, as if the contract need parameter, wallet will be displayed in the compilation process of contract and provide the parameter input box, after the contract parameters with the corresponding input deployer can normal deployment contract,
So actually deploy contracts when the process is how to do? This article provides a code example, the deployment of intelligent contract when the incoming parameters, and successfully deployed,
Still use a standard erc20 token intelligent contract for example,
1. Compile intelligence
First local solidity compile environment, install command:
C: & gt; NPM install - g solc//the default install the latest version
C: & gt; NPM install - g [email protected]//installation specified version
Enters TestToken20. Sol directory and compile contract:
D: & gt; Solcjs - optimize - bin - abi -o bin TestToken20. Sol
After the operation, will automatically generate a bin directory, output TestToken20. Abi and TestToken20. Bin to the bin directory, TestToken20. Abi inside is the content of the abi, TestToken20. Bin is put inside the contents of the bytecode,
2. The deployment of
Use the following code deployment contracts, direct the node execution,
Var Chain3=the require (' Chain3 ');
Var chain3=new chain3 (new chain3. Will. HttpProvider (' http://localhost:8545 '));
//deploy contract
Chain3. Personal. UnlockAccount (chain3. MC. Accounts [0], 'password', 0).
Var totalSupply=1000000;
Var name="erc20Token";
Var decimals=18;
Var symbol="token";
Var erc20TokenContract=chain3. MC. Contract ([{" constant ": true," inputs ": []," name ":" name ", "outputs" :......, "name" : "Approval", "type" : "the event"}));//build intelligent contracts the abi
Var subchainbase=erc20TokenContract. New (
TotalSupply,
The name,
Decimals,
Symbol,
{
From: chain3. MC. Accounts [0],
Data: '0 x608060405234801561001057600080... 00029 ',//compile intelligent bin, with 0 x
Gas: '9000000'
{} function (e, contract)
The console. The log (e, contract);
If (typeof contract. The address! Undefined==' ') {
The console. The log (' Contract mined! Address: '+ contract. The address +' transactionHash: '+ contract. TransactionHash);
}
})
Introduced into four parameters, parameters of intelligent contracts needed,
Resulting from the execution:
To the browser query result:
The deployment was successful!