控制台
控制台能以IPC的方式直接连接区块链节点进程。使用控制台,能直接查看到区块链上的信息。若需要更直观更全面的区块链数据展现,请使用FISCO-BCOS的区块链浏览器。
登陆控制台
连接节点的data目录下的geth.ipc文件。
- ethconsole /mydata/node0/data/geth.ipc
登录成功,可看到successful字样。
- Connecting to node at /mydata/nodedata-1/data/geth.ipc
- Connection successful.
- Current block number: 37
- Entering interactive mode.
- >
查看区块
如查看块高为2的区块
- web3.eth.getBlock(2,console.log)
可得到相应的区块信息
- > null { author: '0x0000000000000000000000000000000000000000',
- difficulty: { [String: '1'] s: 1, e: 0, c: [ 1 ] },
- extraData: '0xd78095312e302b2b302d524c696e75782f672b2b2f496e74',
- gasLimit: 2000000000,
- gasUsed: 33245,
- genIndex: '0x0',
- hash: '0xa3c2b1eda74f26c688e78bffcc71c8561e49dc70fbfbd71b85c3b79a2c16bc81',
- logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
- miner: '0x0000000000000000000000000000000000000000',
- number: 2,
- parentHash: '0x96d095047e68d4db8ae0c74638cf6365d5ee7fbc329d50a5a78a85189e1b105e',
- receiptsRoot: '0xb668c383b2ee76f9e2d0a8b0d9b301fb825896a9a597268ca3cbdd979c4a53da',
- sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
- size: 71,
- stateRoot: '0x20993fb96c5a26eb9f158c194bcd4da845afde2c2095e359259001279de23ec2',
- timestamp: 1513087469641,
- totalDifficulty: { [String: '2'] s: 1, e: 0, c: [ 2 ] },
- transactions: [ '0x63749a62851b52f9263e3c9a791369c7380acc5a9b6ee55dabd9c1013634e355' ],
- transactionsRoot: '0xc9c0b09f236fba3bad81f6fb92b9ca03b6ccb1aaf53ef600621c0a0fd0fd4bb1',
- uncles: [] }
查看交易
根据交易哈希查看交易。如,使用之前调用HelloWord的合约的交易哈希。
- web3.eth.getTransaction('0x63749a62851b52f9263e3c9a791369c7380acc5a9b6ee55dabd9c1013634e355',console.log)
可得到相应的交易信息
- > null { blockHash: '0xa3c2b1eda74f26c688e78bffcc71c8561e49dc70fbfbd71b85c3b79a2c16bc81',
- blockNumber: 2,
- from: '0x04804c06677d2009e52ca96c825d38056292cab6',
- gas: 30000000,
- gasPrice: { [String: '0'] s: 1, e: 0, c: [ 0 ] },
- hash: '0x63749a62851b52f9263e3c9a791369c7380acc5a9b6ee55dabd9c1013634e355',
- input: '0x4ed3885e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b48656c6c6f576f726c6421000000000000000000000000000000000000000000',
- nonce: 67506452,
- to: '0x1d2047204130de907799adaea85c511c7ce85b6d',
- transactionIndex: 0,
- value: { [String: '0'] s: 1, e: 0, c: [ 0 ] } }
查看交易回执
根据交易哈希查看交易回执。如,使用之前调用HelloWord的合约的交易哈希。
- web3.eth.getTransactionReceipt('0x63749a62851b52f9263e3c9a791369c7380acc5a9b6ee55dabd9c1013634e355',console.log)
可得到相应的交易回执
- > null { blockHash: '0xa3c2b1eda74f26c688e78bffcc71c8561e49dc70fbfbd71b85c3b79a2c16bc81',
- blockNumber: 2,
- contractAddress: '0x0000000000000000000000000000000000000000',
- cumulativeGasUsed: 33245,
- gasUsed: 33245,
- logs: [],
- transactionHash: '0x63749a62851b52f9263e3c9a791369c7380acc5a9b6ee55dabd9c1013634e355',
- transactionIndex: 0 }
查看合约代码
根据交易合约地址查看合约。如,用之前部署的HelloWorld合约地址。
- web3.eth.getCode('0x1d2047204130de907799adaea85c511c7ce85b6d',console.log)
可以得到HelloWorld的合约二进制代码
- > null '0x60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634ed3885e146100485780636d4ce63c146100a557600080fd5b341561005357600080fd5b6100a3600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610133565b005b34156100b057600080fd5b6100b861014d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f85780820151818401526020810190506100dd565b50505050905090810190601f1680156101255780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b80600090805190602001906101499291906101f5565b5050565b610155610275565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101eb5780601f106101c0576101008083540402835291602001916101eb565b820191906000526020600020905b8154815290600101906020018083116101ce57829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061023657805160ff1916838001178555610264565b82800160010185558215610264579182015b82811115610263578251825591602001919060010190610248565b5b5090506102719190610289565b5090565b602060405190810160405280600081525090565b6102ab91905b808211156102a757600081600090555060010161028f565b5090565b905600a165627a7a7230582021681cb0ea5b1c4364a4f5e37f12e84241310a74ee462b1a19658b3acc26c6cb0029'
查看节点连接
执行
- //ethconsole版本不同命令稍有不同
- web3.admin.getPeers(console.log)
- //或
- web3.admin.peers(console.log)
可看到连接了其它的节点
- > null [ { caps: [ 'eth/62', 'eth/63', 'pbft/63' ],
- height: '0x25',
- id: 'b5adf6440bb0fe7c337eccfda9259985ee42c1c94e0d357e813f905b6c0fa2049d45170b78367649dd0b8b5954ee919bf50c1398a373ca777e6329bd0c4b82e8',
- lastPing: 0,
- name: 'eth/v1.0/Linux/g++/Interpreter/RelWithDebInfo/0/',
- network: { remoteAddress: '127.0.0.1:30403' },
- notes: { ask: 'Nothing', manners: 'nice', sync: 'holding & needed' } } ]
当前内容版权归 FISCO BCOS 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 FISCO BCOS .