我是靠谱客的博主 悲凉睫毛膏,最近开发中收集的这篇文章主要介绍Geth 常用操作,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

创建账户

> personal.newAccount("abc")  # abc为账户密码
"0x079ffc39b9e5bcaa23134659f5d25320b9c32f15"

赋值

> acc1=eth.accounts[1]
"0x079ffc39b9e5bcaa23134659f5d25320b9c32f15"

转账

> eth.sendTransaction({from:acc0,to:acc1,value:web3.toWei(1,'ether')})
"0xa70b90819303ece8024598ebb747684fd221d377970bef351d865bd4c6cd64e5"

查询余额

> eth.getBalance(acc1)
1000000000000000000

Mine

> miner.start(1)  #参数1为线程数,表示使用1个线程
null

Stop mine

> miner.stop()
null

查看某区块信息

> eth.getBlock(22)  #22区块号
{
  difficulty: 132352,
  extraData: "0xd883010a10846765746888676f312e31372e35856c696e7578",
  gasLimit: 8000000,
  gasUsed: 0,
  hash: "0x55b16b5d1d8350c6463dfe1f0af66e6dc163c532bfe3b41ce3d7b31807386d2b",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0xb151a6dfa0f453402518bcd48adc876da4feb3f2",
  mixHash: "0xbb6639829b0485c1bfb551ff91459273cb1d51a639a20ec767a22991bb8d9929",
  nonce: "0x42d8fbd27f0ef7e2",
  number: 22,
  parentHash: "0xb11d2a0a2c19a4dba85886c6f9ade75f752a6fd9842c9bdf0a1eb81a7b027e73",
  receiptsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  size: 536,
  stateRoot: "0x6f0d2574c59438b8ca77fe819b25bb19fe340cb150eeeb8cc2fb7ad86ec86ef5",
  timestamp: 1649161965,
  totalDifficulty: 2897537,
  transactions: [],
  transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
  uncles: []
}
> 

查看交易

> eth.getTransaction('0xe53630a8f61e6226b6174a21e70caf8365c70b313f415148df261ab55ca8794f')
{
  blockHash: "0x32ea36a7ac305c473563d4390828e9224f04147068c7042a23175a8ae9543b09",
  blockNumber: 8826,
  from: "0x8e569fbd8e6af2cfcdf61f41baac9109aae19f96",
  gas: 58103,
  gasPrice: 1000000000,
  hash: "0xe53630a8f61e6226b6174a21e70caf8365c70b313f415148df261ab55ca8794f",
  input: "0xd22057a994fe36c4e11dca50db4ffcb6ce72007cc70df4154281e512da3aaadc1f8443240000000000000000000000004ad4b32368c55e974ba6d4cf2c15f26f76fdaaac",
  nonce: 76,
  r: "0x2756f0cba484922ed03451d2f6d9f170e10fde2c263781d1d0844776d051b8b7",
  s: "0x6fc86eb4202a80ce3c3af1a377c310a5a1c063e035adb8014035e1bff3762541",
  to: "0x808800b29160677a9b21e6117dc6782cc6cfc32b",
  transactionIndex: 0,
  type: "0x0",
  v: "0x140",
  value: 0
}

查看交易票据

> eth.getTransactionReceipt('0xe53630a8f61e6226b6174a21e70caf8365c70b313f415148df261ab55ca8794f')
{
  blockHash: "0x32ea36a7ac305c473563d4390828e9224f04147068c7042a23175a8ae9543b09",
  blockNumber: 8826,
  contractAddress: null,
  cumulativeGasUsed: 58103,
  effectiveGasPrice: 1000000000,
  from: "0x8e569fbd8e6af2cfcdf61f41baac9109aae19f96",
  gasUsed: 58103,
  logs: [{
      address: "0x808800b29160677a9b21e6117dc6782cc6cfc32b",
      blockHash: "0x32ea36a7ac305c473563d4390828e9224f04147068c7042a23175a8ae9543b09",
      blockNumber: 8826,
      data: "0x0000000000000000000000008e569fbd8e6af2cfcdf61f41baac9109aae19f96",
      logIndex: 0,
      removed: false,
      topics: ["0x60de86555c28ac98de04e6a59079b111e8f56775b2a35bdcd79561d34813c543", "0x94fe36c4e11dca50db4ffcb6ce72007cc70df4154281e512da3aaadc1f844324", "0x0000000000000000000000004ad4b32368c55e974ba6d4cf2c15f26f76fdaaac"],
      transactionHash: "0xe53630a8f61e6226b6174a21e70caf8365c70b313f415148df261ab55ca8794f",
      transactionIndex: 0
  }],
  logsBloom: "0x00000000000000000000000000000000200000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000080000000008000000010000000000000000008000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000001000020001000000000000000000000000000000000000000000000000000000000000000000",
  status: "0x1",
  to: "0x808800b29160677a9b21e6117dc6782cc6cfc32b",
  transactionHash: "0xe53630a8f61e6226b6174a21e70caf8365c70b313f415148df261ab55ca8794f",
  transactionIndex: 0,
  type: "0x0"
}

最后

以上就是悲凉睫毛膏为你收集整理的Geth 常用操作的全部内容,希望文章能够帮你解决Geth 常用操作所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(36)

评论列表共有 0 条评论

立即
投稿
返回
顶部