본문 바로가기
블록체인

콘솔에서 계약 배포, 실행

by ^..^v 2019. 10. 4.
728x90
반응형

관리자 권한으로 명령어창 실행 

 

 

npm을 이용해서 solc, web3 설치

 

 

텍스트 에디터를 이용하여 c:\testnet\HelloWorld.sol 파일을 작성

 

 

solc 모듈을 이용하여 계약을 컴파일

 

 

계약 배포에 필요한 ABI 정보와 바이트 코드를 추출

 

 

web3를 이용한 계약 배포 및 실행

Web3 {
  _requestManager:
   RequestManager {
     provider:
      HttpProvider {
        host: 'http://localhost:8545',
        timeout: 0,
        user: undefined,
        password: undefined,
        headers: undefined },
     polls: {},
     timeout: null },
  currentProvider:
   HttpProvider {
     host: 'http://localhost:8545',
     timeout: 0,
     user: undefined,
     password: undefined,
     headers: undefined },
  eth:
   Eth {
     _requestManager:
      RequestManager { provider: [HttpProvider], polls: {}, timeout: null },
     getBalance:
      { [Function: send] request: [Function: bound ], call: 'eth_getBalance' },
     getStorageAt:
      { [Function: send] request: [Function: bound ], call: 'eth_getStorageAt' },
     getCode:
      { [Function: send] request: [Function: bound ], call: 'eth_getCode' },
     getBlock:
      { [Function: send] request: [Function: bound ], call: [Function: blockCall] },
     getUncle:
      { [Function: send] request: [Function: bound ], call: [Function: uncleCall] },
     getCompilers:
      { [Function: send] request: [Function: bound ], call: 'eth_getCompilers' },
     getBlockTransactionCount:
      { [Function: send]
        request: [Function: bound ],
        call: [Function: getBlockTransactionCountCall] },
     getBlockUncleCount:
      { [Function: send]
        request: [Function: bound ],
        call: [Function: uncleCountCall] },
     getTransaction:
      { [Function: send]
        request: [Function: bound ],
        call: 'eth_getTransactionByHash' },
     getTransactionFromBlock:
      { [Function: send]
        request: [Function: bound ],
        call: [Function: transactionFromBlockCall] },
     getTransactionReceipt:
      { [Function: send]
        request: [Function: bound ],
        call: 'eth_getTransactionReceipt' },
     getTransactionCount:
      { [Function: send] request: [Function: bound ], call: 'eth_getTransactionCount' },
     call:
      { [Function: send] request: [Function: bound ], call: 'eth_call' },
     estimateGas:
      { [Function: send] request: [Function: bound ], call: 'eth_estimateGas' },
     sendRawTransaction:
      { [Function: send] request: [Function: bound ], call: 'eth_sendRawTransaction' },
     signTransaction:
      { [Function: send] request: [Function: bound ], call: 'eth_signTransaction' },
     sendTransaction:
      { [Function: send] request: [Function: bound ], call: 'eth_sendTransaction' },
     sign:
      { [Function: send] request: [Function: bound ], call: 'eth_sign' },
     compile:
      { solidity: [Function], lll: [Function], serpent: [Function] },
     submitWork:
      { [Function: send] request: [Function: bound ], call: 'eth_submitWork' },
     getWork:
      { [Function: send] request: [Function: bound ], call: 'eth_getWork' },
     coinbase: [Getter],
     getCoinbase: { [Function: get] request: [Function: bound ] },
     mining: [Getter],
     getMining: { [Function: get] request: [Function: bound ] },
     hashrate: [Getter],
     getHashrate: { [Function: get] request: [Function: bound ] },
     syncing: [Getter],
     getSyncing: { [Function: get] request: [Function: bound ] },
     gasPrice: [Getter],
     getGasPrice: { [Function: get] request: [Function: bound ] },
     accounts: [Getter],
     getAccounts: { [Function: get] request: [Function: bound ] },
     blockNumber: [Getter],
     getBlockNumber: { [Function: get] request: [Function: bound ] },
     protocolVersion: [Getter],
     getProtocolVersion: { [Function: get] request: [Function: bound ] },
     iban:
      { [Function: Iban]
        fromAddress: [Function],
        fromBban: [Function],
        createIndirect: [Function],
        isValid: [Function] },
     sendIBANTransaction: [Function: bound transfer] },
  db:
   DB {
     _requestManager:
      RequestManager { provider: [HttpProvider], polls: {}, timeout: null },
     putString:
      { [Function: send] request: [Function: bound ], call: 'db_putString' },
     getString:
      { [Function: send] request: [Function: bound ], call: 'db_getString' },
     putHex:
      { [Function: send] request: [Function: bound ], call: 'db_putHex' },
     getHex:
      { [Function: send] request: [Function: bound ], call: 'db_getHex' } },
  shh:
   Shh {
     _requestManager:
      RequestManager { provider: [HttpProvider], polls: {}, timeout: null },
     version:
      { [Function: send] request: [Function: bound ], call: 'shh_version' },
     info:
      { [Function: send] request: [Function: bound ], call: 'shh_info' },
     setMaxMessageSize:
      { [Function: send] request: [Function: bound ], call: 'shh_setMaxMessageSize' },
     setMinPoW:
      { [Function: send] request: [Function: bound ], call: 'shh_setMinPoW' },
     markTrustedPeer:
      { [Function: send] request: [Function: bound ], call: 'shh_markTrustedPeer' },
     newKeyPair:
      { [Function: send] request: [Function: bound ], call: 'shh_newKeyPair' },
     addPrivateKey:
      { [Function: send] request: [Function: bound ], call: 'shh_addPrivateKey' },
     deleteKeyPair:
      { [Function: send] request: [Function: bound ], call: 'shh_deleteKeyPair' },
     hasKeyPair:
      { [Function: send] request: [Function: bound ], call: 'shh_hasKeyPair' },
     getPublicKey:
      { [Function: send] request: [Function: bound ], call: 'shh_getPublicKey' },
     getPrivateKey:
      { [Function: send] request: [Function: bound ], call: 'shh_getPrivateKey' },
     newSymKey:
      { [Function: send] request: [Function: bound ], call: 'shh_newSymKey' },
     addSymKey:
      { [Function: send] request: [Function: bound ], call: 'shh_addSymKey' },
     generateSymKeyFromPassword:
      { [Function: send]
        request: [Function: bound ],
        call: 'shh_generateSymKeyFromPassword' },
     hasSymKey:
      { [Function: send] request: [Function: bound ], call: 'shh_hasSymKey' },
     getSymKey:
      { [Function: send] request: [Function: bound ], call: 'shh_getSymKey' },
     deleteSymKey:
      { [Function: send] request: [Function: bound ], call: 'shh_deleteSymKey' },
     post:
      { [Function: send] request: [Function: bound ], call: 'shh_post' } },
  net:
   Net {
     _requestManager:
      RequestManager { provider: [HttpProvider], polls: {}, timeout: null },
     listening: [Getter],
     getListening: { [Function: get] request: [Function: bound ] },
     peerCount: [Getter],
     getPeerCount: { [Function: get] request: [Function: bound ] } },
  personal:
   Personal {
     _requestManager:
      RequestManager { provider: [HttpProvider], polls: {}, timeout: null },
     newAccount:
      { [Function: send] request: [Function: bound ], call: 'personal_newAccount' },
     importRawKey:
      { [Function: send] request: [Function: bound ], call: 'personal_importRawKey' },
     unlockAccount:
      { [Function: send] request: [Function: bound ], call: 'personal_unlockAccount' },
     ecRecover:
      { [Function: send] request: [Function: bound ], call: 'personal_ecRecover' },
     sign:
      { [Function: send] request: [Function: bound ], call: 'personal_sign' },
     sendTransaction:
      { [Function: send]
        request: [Function: bound ],
        call: 'personal_sendTransaction' },
     lockAccount:
      { [Function: send] request: [Function: bound ], call: 'personal_lockAccount' },
     listAccounts: [Getter],
     getListAccounts: { [Function: get] request: [Function: bound ] } },
  bzz:
   Swarm {
     _requestManager:
      RequestManager { provider: [HttpProvider], polls: {}, timeout: null },
     blockNetworkRead:
      { [Function: send] request: [Function: bound ], call: 'bzz_blockNetworkRead' },
     syncEnabled:
      { [Function: send] request: [Function: bound ], call: 'bzz_syncEnabled' },
     swapEnabled:
      { [Function: send] request: [Function: bound ], call: 'bzz_swapEnabled' },
     download:
      { [Function: send] request: [Function: bound ], call: 'bzz_download' },
     upload:
      { [Function: send] request: [Function: bound ], call: 'bzz_upload' },
     retrieve:
      { [Function: send] request: [Function: bound ], call: 'bzz_retrieve' },
     store:
      { [Function: send] request: [Function: bound ], call: 'bzz_store' },
     get:
      { [Function: send] request: [Function: bound ], call: 'bzz_get' },
     put:
      { [Function: send] request: [Function: bound ], call: 'bzz_put' },
     modify:
      { [Function: send] request: [Function: bound ], call: 'bzz_modify' },
     hive: [Getter],
     getHive: { [Function: get] request: [Function: bound ] },
     info: [Getter],
     getInfo: { [Function: get] request: [Function: bound ] } },
  settings:
   Settings { defaultBlock: 'latest', defaultAccount: undefined },
  version:
   { api: '0.20.7',
     node: [Getter],
     getNode: { [Function: get] request: [Function: bound ] },
     network: [Getter],
     getNetwork: { [Function: get] request: [Function: bound ] },
     ethereum: [Getter],
     getEthereum: { [Function: get] request: [Function: bound ] },
     whisper: [Getter],
     getWhisper: { [Function: get] request: [Function: bound ] } },
  providers:
   { HttpProvider: [Function: HttpProvider],
     IpcProvider: [Function: IpcProvider] },
  _extend:
   { [Function: ex]
     formatters:
      { inputDefaultBlockNumberFormatter: [Function: inputDefaultBlockNumberFormatter],
        inputBlockNumberFormatter: [Function: inputBlockNumberFormatter],
        inputCallFormatter: [Function: inputCallFormatter],
        inputTransactionFormatter: [Function: inputTransactionFormatter],
        inputAddressFormatter: [Function: inputAddressFormatter],
        inputPostFormatter: [Function: inputPostFormatter],
        outputBigNumberFormatter: [Function: outputBigNumberFormatter],
        outputTransactionFormatter: [Function: outputTransactionFormatter],
        outputTransactionReceiptFormatter: [Function: outputTransactionReceiptFormatter],
        outputBlockFormatter: [Function: outputBlockFormatter],
        outputLogFormatter: [Function: outputLogFormatter],
        outputPostFormatter: [Function: outputPostFormatter],
        outputSyncingFormatter: [Function: outputSyncingFormatter] },
     utils:
      { padLeft: [Function: padLeft],
        padRight: [Function: padRight],
        toHex: [Function: toHex],
        toDecimal: [Function: toDecimal],
        fromDecimal: [Function: fromDecimal],
        toUtf8: [Function: toUtf8],
        toAscii: [Function: toAscii],
        fromUtf8: [Function: fromUtf8],
        fromAscii: [Function: fromAscii],
        transformToFullName: [Function: transformToFullName],
        extractDisplayName: [Function: extractDisplayName],
        extractTypeName: [Function: extractTypeName],
        toWei: [Function: toWei],
        fromWei: [Function: fromWei],
        toBigNumber: [Function: toBigNumber],
        toTwosComplement: [Function: toTwosComplement],
        toAddress: [Function: toAddress],
        isBigNumber: [Function: isBigNumber],
        isStrictAddress: [Function: isStrictAddress],
        isAddress: [Function: isAddress],
        isChecksumAddress: [Function: isChecksumAddress],
        toChecksumAddress: [Function: toChecksumAddress],
        isFunction: [Function: isFunction],
        isString: [Function: isString],
        isObject: [Function: isObject],
        isBoolean: [Function: isBoolean],
        isArray: [Function: isArray],
        isJson: [Function: isJson],
        isBloom: [Function: isBloom],
        isTopic: [Function: isTopic] },
     Method: [Function: Method],
     Property: [Function: Property] } }

 

ContractFactory {
  eth:
   Eth {
     _requestManager:
      RequestManager { provider: [HttpProvider], polls: {}, timeout: null },
     getBalance:
      { [Function: send] request: [Function: bound ], call: 'eth_getBalance' },
     getStorageAt:
      { [Function: send] request: [Function: bound ], call: 'eth_getStorageAt' },
     getCode:
      { [Function: send] request: [Function: bound ], call: 'eth_getCode' },
     getBlock:
      { [Function: send] request: [Function: bound ], call: [Function: blockCall] },
     getUncle:
      { [Function: send] request: [Function: bound ], call: [Function: uncleCall] },
     getCompilers:
      { [Function: send] request: [Function: bound ], call: 'eth_getCompilers' },
     getBlockTransactionCount:
      { [Function: send]
        request: [Function: bound ],
        call: [Function: getBlockTransactionCountCall] },
     getBlockUncleCount:
      { [Function: send]
        request: [Function: bound ],
        call: [Function: uncleCountCall] },
     getTransaction:
      { [Function: send]
        request: [Function: bound ],
        call: 'eth_getTransactionByHash' },
     getTransactionFromBlock:
      { [Function: send]
        request: [Function: bound ],
        call: [Function: transactionFromBlockCall] },
     getTransactionReceipt:
      { [Function: send]
        request: [Function: bound ],
        call: 'eth_getTransactionReceipt' },
     getTransactionCount:
      { [Function: send] request: [Function: bound ], call: 'eth_getTransactionCount' },
     call:
      { [Function: send] request: [Function: bound ], call: 'eth_call' },
     estimateGas:
      { [Function: send] request: [Function: bound ], call: 'eth_estimateGas' },
     sendRawTransaction:
      { [Function: send] request: [Function: bound ], call: 'eth_sendRawTransaction' },
     signTransaction:
      { [Function: send] request: [Function: bound ], call: 'eth_signTransaction' },
     sendTransaction:
      { [Function: send] request: [Function: bound ], call: 'eth_sendTransaction' },
     sign:
      { [Function: send] request: [Function: bound ], call: 'eth_sign' },
     compile:
      { solidity: [Function], lll: [Function], serpent: [Function] },
     submitWork:
      { [Function: send] request: [Function: bound ], call: 'eth_submitWork' },
     getWork:
      { [Function: send] request: [Function: bound ], call: 'eth_getWork' },
     coinbase: [Getter],
     getCoinbase: { [Function: get] request: [Function: bound ] },
     mining: [Getter],
     getMining: { [Function: get] request: [Function: bound ] },
     hashrate: [Getter],
     getHashrate: { [Function: get] request: [Function: bound ] },
     syncing: [Getter],
     getSyncing: { [Function: get] request: [Function: bound ] },
     gasPrice: [Getter],
     getGasPrice: { [Function: get] request: [Function: bound ] },
     accounts: [Getter],
     getAccounts: { [Function: get] request: [Function: bound ] },
     blockNumber: [Getter],
     getBlockNumber: { [Function: get] request: [Function: bound ] },
     protocolVersion: [Getter],
     getProtocolVersion: { [Function: get] request: [Function: bound ] },
     iban:
      { [Function: Iban]
        fromAddress: [Function],
        fromBban: [Function],
        createIndirect: [Function],
        isValid: [Function] },
     sendIBANTransaction: [Function: bound transfer] },
  abi:
   [ { constant: true,
       inputs: [],
       name: 'say',
       outputs: [Array],
       payable: false,
       stateMutability: 'view',
       type: 'function' },
     { constant: false,
       inputs: [Array],
       name: 'setGreeting',
       outputs: [],
       payable: false,
       stateMutability: 'nonpayable',
       type: 'function' },
     { constant: true,
       inputs: [],
       name: 'greeting',
       outputs: [Array],
       payable: false,
       stateMutability: 'view',
       type: 'function' },
     { inputs: [Array],
       payable: false,
       stateMutability: 'nonpayable',
       type: 'constructor' } ],
  new: { [Function] getData: [Function: bound ] } }

 

Contract {
  _eth:
   Eth {
     _requestManager:
      RequestManager { provider: [HttpProvider], polls: {}, timeout: null },
     getBalance:
      { [Function: send] request: [Function: bound ], call: 'eth_getBalance' },
     getStorageAt:
      { [Function: send] request: [Function: bound ], call: 'eth_getStorageAt' },
     getCode:
      { [Function: send] request: [Function: bound ], call: 'eth_getCode' },
     getBlock:
      { [Function: send] request: [Function: bound ], call: [Function: blockCall] },
     getUncle:
      { [Function: send] request: [Function: bound ], call: [Function: uncleCall] },
     getCompilers:
      { [Function: send] request: [Function: bound ], call: 'eth_getCompilers' },
     getBlockTransactionCount:
      { [Function: send]
        request: [Function: bound ],
        call: [Function: getBlockTransactionCountCall] },
     getBlockUncleCount:
      { [Function: send]
        request: [Function: bound ],
        call: [Function: uncleCountCall] },
     getTransaction:
      { [Function: send]
        request: [Function: bound ],
        call: 'eth_getTransactionByHash' },
     getTransactionFromBlock:
      { [Function: send]
        request: [Function: bound ],
        call: [Function: transactionFromBlockCall] },
     getTransactionReceipt:
      { [Function: send]
        request: [Function: bound ],
        call: 'eth_getTransactionReceipt' },
     getTransactionCount:
      { [Function: send] request: [Function: bound ], call: 'eth_getTransactionCount' },
     call:
      { [Function: send] request: [Function: bound ], call: 'eth_call' },
     estimateGas:
      { [Function: send] request: [Function: bound ], call: 'eth_estimateGas' },
     sendRawTransaction:
      { [Function: send] request: [Function: bound ], call: 'eth_sendRawTransaction' },
     signTransaction:
      { [Function: send] request: [Function: bound ], call: 'eth_signTransaction' },
     sendTransaction:
      { [Function: send] request: [Function: bound ], call: 'eth_sendTransaction' },
     sign:
      { [Function: send] request: [Function: bound ], call: 'eth_sign' },
     compile:
      { solidity: [Function], lll: [Function], serpent: [Function] },
     submitWork:
      { [Function: send] request: [Function: bound ], call: 'eth_submitWork' },
     getWork:
      { [Function: send] request: [Function: bound ], call: 'eth_getWork' },
     coinbase: [Getter],
     getCoinbase: { [Function: get] request: [Function: bound ] },
     mining: [Getter],
     getMining: { [Function: get] request: [Function: bound ] },
     hashrate: [Getter],
     getHashrate: { [Function: get] request: [Function: bound ] },
     syncing: [Getter],
     getSyncing: { [Function: get] request: [Function: bound ] },
     gasPrice: [Getter],
     getGasPrice: { [Function: get] request: [Function: bound ] },
     accounts: [Getter],
     getAccounts: { [Function: get] request: [Function: bound ] },
     blockNumber: [Getter],
     getBlockNumber: { [Function: get] request: [Function: bound ] },
     protocolVersion: [Getter],
     getProtocolVersion: { [Function: get] request: [Function: bound ] },
     iban:
      { [Function: Iban]
        fromAddress: [Function],
        fromBban: [Function],
        createIndirect: [Function],
        isValid: [Function] },
     sendIBANTransaction: [Function: bound transfer] },
  transactionHash:
   '0xb75e585b4b6f1e52cd24db626d3b5d7c934cb8dddd1301a60a97883171708b00',
  address: undefined,
  abi:
   [ { constant: true,
       inputs: [],
       name: 'say',
       outputs: [Array],
       payable: false,
       stateMutability: 'view',
       type: 'function' },
     { constant: false,
       inputs: [Array],
       name: 'setGreeting',
       outputs: [],
       payable: false,
       stateMutability: 'nonpayable',
       type: 'function' },
     { constant: true,
       inputs: [],
       name: 'greeting',
       outputs: [Array],
       payable: false,
       stateMutability: 'view',
       type: 'function' },
     { inputs: [Array],
       payable: false,
       stateMutability: 'nonpayable',
       type: 'constructor' } ] }

728x90
반응형

'블록체인' 카테고리의 다른 글

단일 머신에서 멀티 노드 실행  (0) 2019.10.08
Remix 환경에서 계약 작성  (0) 2019.10.08
Postman을 이용한 RPC 테스트  (0) 2019.10.04
JSON-RPC 활성화  (0) 2019.10.04
수수료가 발생하는 거래  (0) 2019.10.04

댓글