-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCounterCommand.js
More file actions
40 lines (25 loc) · 16 KB
/
Copy pathCounterCommand.js
File metadata and controls
40 lines (25 loc) · 16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
web3.personal.unlockAccount(web3.eth.accounts[0], "1234");
const abi = '[{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"employees\",\"outputs\":[{\"name\":\"empNum\",\"type\":\"uint256\"},{\"name\":\"empName\",\"type\":\"string\"},{\"name\":\"empScore\",\"type\":\"uint256\"},{\"name\":\"empTrustScore\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"exsited\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"setEmp\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"sumOfVerifyingScore\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_empNum\",\"type\":\"uint256\"}],\"name\":\"getEmpScore\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"isVerified\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"cmdScore\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_issuingCmdEmpNum\",\"type\":\"uint256\"}],\"name\":\"setIssuingEmp\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_empNum\",\"type\":\"uint256\"}],\"name\":\"issueCmd_1\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"verify\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"__empNum\",\"type\":\"uint256\"}],\"name\":\"zeroScoreToEmp\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]'
const CommandContractFactory = web3.eth.contract(JSON.parse(abi));
const bin = '0x6080604052600560005560006001556000600260006101000a81548160ff0219169083151502179055503480156200003657600080fd5b5062000052600362000058640100000000026401000000009004565b620009ab565b6200007162000092640100000000026401000000009004565b506200008f60018203620008ab640100000000026401000000009004565b50565b6000600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017fec82acec9b9031000000000000000000000000000000000000000000000000008152508152602001600181526020016000815250908060018154018082558091505090600182039060005260206000209060040201600090919290919091506000820151816000015560208201518160010190805190602001906200014a929190620008fc565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017fec82acec9b90320000000000000000000000000000000000000000000000000081525081526020016002815260200160018152509080600181540180825580915050906001820390600052602060002090600402016000909192909190915060008201518160000155602082015181600101908051906020019062000218929190620008fc565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017feb8c80eba6ac3100000000000000000000000000000000000000000000000000815250815260200160028152602001600281525090806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001019080519060200190620002e6929190620008fc565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017feb8c80eba6ac3200000000000000000000000000000000000000000000000000815250815260200160038152602001600281525090806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001019080519060200190620003b4929190620008fc565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017fecb0a8ec9ea5310000000000000000000000000000000000000000000000000081525081526020016003815260200160038152509080600181540180825580915050906001820390600052602060002090600402016000909192909190915060008201518160000155602082015181600101908051906020019062000482929190620008fc565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017fecb0a8ec9ea5320000000000000000000000000000000000000000000000000081525081526020016004815260200160038152509080600181540180825580915050906001820390600052602060002090600402016000909192909190915060008201518160000155602082015181600101908051906020019062000550929190620008fc565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600681526020017feab3bcec9ea500000000000000000000000000000000000000000000000000008152508152602001600581526020016003815250908060018154018082558091505090600182039060005260206000209060040201600090919290919091506000820151816000015560208201518160010190805190602001906200061e929190620008fc565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600681526020017fed8c80ec9ea50000000000000000000000000000000000000000000000000000815250815260200160068152602001600581525090806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001019080519060200190620006ec929190620008fc565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600981526020017febb680ec82acec9ea50000000000000000000000000000000000000000000000815250815260200160078152602001600481525090806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001019080519060200190620007ba929190620008fc565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600681526020017fec82acec9ea5000000000000000000000000000000000000000000000000000081525081526020016009815260200160088152509080600181540180825580915050906001820390600052602060002090600402016000909192909190915060008201518160000155602082015181600101908051906020019062000888929190620008fc565b506040820151816002015560608201518160030155505050600380549050905090565b6000600382815481101515620008bd57fe5b9060005260206000209060040201600201819055506000600382815481101515620008e457fe5b90600052602060002090600402016003018190555050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200093f57805160ff191683800117855562000970565b8280016001018555821562000970579182015b828111156200096f57825182559160200191906001019062000952565b5b5090506200097f919062000983565b5090565b620009a891905b80821115620009a45760008160009055506001016200098a565b5090565b90565b610f8380620009bb6000396000f3006080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634739326b146100b457806349edc1401461016f5780635ec027a21461019e57806371e2e5e4146101c957806373022d1e146101f457806380007e83146102355780638d084c1714610264578063b5cf5d491461028f578063bf6239fe146102bc578063fc735e99146102dc578063fdf3d0cc146102fe575b600080fd5b3480156100c057600080fd5b506100df6004803603810190808035906020019092919050505061032b565b6040518085815260200180602001848152602001838152602001828103825285818151815260200191508051906020019080838360005b83811015610131578082015181840152602081019050610116565b50505050905090810190601f16801561015e5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390f35b34801561017b57600080fd5b50610184610402565b604051808215151515815260200191505060405180910390f35b3480156101aa57600080fd5b506101b3610415565b6040518082815260200191505060405180910390f35b3480156101d557600080fd5b506101de610c1a565b6040518082815260200191505060405180910390f35b34801561020057600080fd5b5061021f60048036038101908080359060200190929190505050610c20565b6040518082815260200191505060405180910390f35b34801561024157600080fd5b5061024a610c4a565b604051808215151515815260200191505060405180910390f35b34801561027057600080fd5b50610279610c5d565b6040518082815260200191505060405180910390f35b34801561029b57600080fd5b506102ba60048036038101908080359060200190929190505050610c63565b005b6102da60048036038101908080359060200190929190505050610cb2565b005b6102e4610cca565b604051808215151515815260200191505060405180910390f35b34801561030a57600080fd5b5061032960048036038101908080359060200190929190505050610e63565b005b60038181548110151561033a57fe5b9060005260206000209060040201600091509050806000015490806001018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103ec5780601f106103c1576101008083540402835291602001916103ec565b820191906000526020600020905b8154815290600101906020018083116103cf57829003601f168201915b5050505050908060020154908060030154905084565b600260019054906101000a900460ff1681565b6000600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017fec82acec9b9031000000000000000000000000000000000000000000000000008152508152602001600181526020016000815250908060018154018082558091505090600182039060005260206000209060040201600090919290919091506000820151816000015560208201518160010190805190602001906104cb929190610eb2565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017fec82acec9b903200000000000000000000000000000000000000000000000000815250815260200160028152602001600181525090806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001019080519060200190610597929190610eb2565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017feb8c80eba6ac3100000000000000000000000000000000000000000000000000815250815260200160028152602001600281525090806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001019080519060200190610663929190610eb2565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017feb8c80eba6ac320000000000000000000000000000000000000000000000000081525081526020016003815260200160028152509080600181540180825580915050906001820390600052602060002090600402016000909192909190915060008201518160000155602082015181600101908051906020019061072f929190610eb2565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017fecb0a8ec9ea531000000000000000000000000000000000000000000000000008152508152602001600381526020016003815250908060018154018082558091505090600182039060005260206000209060040201600090919290919091506000820151816000015560208201518160010190805190602001906107fb929190610eb2565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600781526020017fecb0a8ec9ea532000000000000000000000000000000000000000000000000008152508152602001600481526020016003815250908060018154018082558091505090600182039060005260206000209060040201600090919290919091506000820151816000015560208201518160010190805190602001906108c7929190610eb2565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600681526020017feab3bcec9ea50000000000000000000000000000000000000000000000000000815250815260200160058152602001600381525090806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001019080519060200190610993929190610eb2565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600681526020017fed8c80ec9ea50000000000000000000000000000000000000000000000000000815250815260200160068152602001600581525090806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001019080519060200190610a5f929190610eb2565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600981526020017febb680ec82acec9ea50000000000000000000000000000000000000000000000815250815260200160078152602001600481525090806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001019080519060200190610b2b929190610eb2565b506040820151816002015560608201518160030155505050600360806040519081016040528060016003805490500181526020016040805190810160405280600681526020017fec82acec9ea50000000000000000000000000000000000000000000000000000815250815260200160098152602001600881525090806001815401808255809150509060018203906000526020600020906004020160009091929091909150600082015181600001556020820151816001019080519060200190610bf7929190610eb2565b506040820151816002015560608201518160030155505050600380549050905090565b60015481565b6000600382815481101515610c3157fe5b9060005260206000209060040201600201549050919050565b600260009054906101000a900460ff1681565b60005481565b6000600382815481101515610c7457fe5b9060005260206000209060040201600201819055506000600382815481101515610c9a57fe5b90600052602060002090600402016003018190555050565b610cba610415565b50610cc760018203610c63565b50565b6000610d71600a424460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b602083101515610d2e5780518252602082019150602081019050602083039250610d09565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060019004811515610d6857fe5b0660ff16610c20565b600160008282540192505081905550610e25600a424460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b602083101515610de25780518252602082019150602081019050602083039250610dbd565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060019004811515610e1c57fe5b0660ff16610e63565b600054600154101515610e4e576001600260006101000a81548160ff0219169083151502179055505b600260009054906101000a900460ff16905090565b6000600382815481101515610e7457fe5b9060005260206000209060040201600201819055506000600382815481101515610e9a57fe5b90600052602060002090600402016003018190555050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610ef357805160ff1916838001178555610f21565b82800160010185558215610f21579182015b82811115610f20578251825591602001919060010190610f05565b5b509050610f2e9190610f32565b5090565b610f5491905b80821115610f50576000816000905550600101610f38565b5090565b905600a165627a7a72305820efc70c3d528ec7371813ff79fcf06125e55bc587f431216ea5424474db1582350029'
console.log("\n\n컨트랙트 배포를 시도합니다... ~~\n\n")
const startTime = Date.now();
const CommandContractInstance = CommandContractFactory.new({
from: web3.eth.accounts[0],
data : bin,
gas: '300000000'
},
function (e,contract) {
if(e) {
console.log("this is e~~~ : \n\n " + e);
}
if(typeof contract.address !== 'undefined') {
const endTime = Date.now();
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash)
console.log("기존 시스템 소요 시간 --> 배포시작: " + startTime + " 배포 마무리: " + endTime + " : "+ (endTime - startTime)+"ms");
console.log("총 소요시간 : " + ((endTime - startTime) / 1000) + "s")
}
}
)