以太坊学习:第十天

学不动了,好多都听不懂,而且对端口网络连接的一点办法都没有,乱撞,以太坊学习就到这吧,有了基础再深入学习


web3.js 1.0中文手册 / web3.eth.getCoinbase - 返回挖矿收益账户 - 汇智网

node控制台进入web3

var Web3 = require('web3')
Web3
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
web3

web3.js

{
  admin: {
    datadir: "/usr/local/GethProjects",
    nodeInfo: {
      enode: "enode://1c2193bd16d2ffa085950163852ac3b7e995529aa93ec6b30edda84aa530f500e13308e1707ed0914d859d070811887da7ee14dbdd6f545ae4199b016111ac5b@127.0.0.1:30303",
      enr: "enr:-Je4QBgi7y0_M2-4d-jdaqS0sRv-hEHG6AvEsHxZ6FZP4gXrcx3fNDrIMH8_B3pC8pOpdpoa0kdqZjGArsrBZQnVpbEWg2V0aMfGhIwcZ7CAgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQMcIZO9FtL_oIWVAWOFKsO36ZVSmqk-xrMO3ahKpTD1AIN0Y3CCdl-DdWRwgnZf",
      id: "2890073dc31178da9117784a10af010f17b008b299aeaeba210a7f6370952632",
      ip: "127.0.0.1",
      listenAddr: "[::]:30303",
      name: "Geth/v1.9.8-stable-d62e9b28/linux-amd64/go1.13.4",
      ports: {
        discovery: 30303,
        listener: 30303
      },
      protocols: {
        eth: {...}
      }
    },
    peers: [{
        caps: [...],
        enode: "enode://fe27ccc5a34d6625ad124eaf8f7b1d1fc0e9aede3b86bd387eaf1247c1aaeb612d6ba5e6e36f41b637d63f941e55f081f95648dd15e1955121a2fee39825641f@165.232.144.191:30300",
        id: "82f1363499c7910a0138357e98016a5291cf046f568b1d44de0bef0d9e1e2d17",
        name: "Geth/RoseliBak/v1.10.0-stable(quorum-v22.1.0)/linux-amd64/go1.17.5",
        network: {...},
        protocols: {...}
    }, {
        caps: [...],
        enode: "enode://3232d616cceb22fc6bc5bb34f24ad00386134acb384eb423f9bab6a19066c4c3d8921e3de6b672530c5803fd39059665a395b6f2d9b4bb565837ee40816eb509@146.19.24.242:30300",
        id: "837c063ac26ca22e355ebc8fd413a5a76ce6e1139d76a54085df6a2c4a8f2eb6",
        name: "Geth/Ofline/v1.10.0-stable(quorum-v22.1.0)/linux-amd64/go1.18.1",
        network: {...},
        protocols: {...}
    }],
    addPeer: function(),
    addTrustedPeer: function(),
    clearHistory: function(),
    exportChain: function(),
    getDatadir: function(callback),
    getNodeInfo: function(callback),
    getPeers: function(callback),
    importChain: function(),
    removePeer: function(),
    removeTrustedPeer: function(),
    sleep: function github.com/ethereum/go-ethereum/console.(*bridge).Sleep-fm(),
    sleepBlocks: function github.com/ethereum/go-ethereum/console.(*bridge).SleepBlocks-fm(),
    startRPC: function(),
    startWS: function(),
    stopRPC: function(),
    stopWS: function()
  },
  bzz: {//bzz:solc相关的组件的对象
    hive: undefined,
    info: undefined,
    blockNetworkRead: function(),
    download: function(),
    get: function(),
    getHive: function(callback),
    getInfo: function(callback),
    modify: function(),
    put: function(),
    retrieve: function(),
    store: function(),
    swapEnabled: function(),
    syncEnabled: function(),
    upload: function()
  },
  currentProvider: {
    newAccount: function(),
    openWallet: function(),
    send: function github.com/ethereum/go-ethereum/console.(*bridge).Send-fm(),
    sendAsync: function github.com/ethereum/go-ethereum/console.(*bridge).Send-fm(),
    sign: function(),
    unlockAccount: function()
  },
  db: {//db:操作区块链底层数据库
    getHex: function(),
    getString: function(),
    putHex: function(),
    putString: function()
  },
  debug: {
    backtraceAt: function(),
    blockProfile: function(),
    chaindbCompact: function(),
    chaindbProperty: function(),
    cpuProfile: function(),
    dumpBlock: function(),
    freeOSMemory: function(),
    freezeClient: function(),
    gcStats: function(),
    getBadBlocks: function(),
    getBlockRlp: function(),
    getModifiedAccountsByHash: function(),
    getModifiedAccountsByNumber: function(),
    goTrace: function(),
    memStats: function(),
    mutexProfile: function(),
    preimage: function(),
    printBlock: function(),
    seedHash: function(),
    setBlockProfileRate: function(),
    setGCPercent: function(),
    setHead: function(),
    setMutexProfileFraction: function(),
    stacks: function(),
    standardTraceBadBlockToFile: function(),
    standardTraceBlockToFile: function(),
    startCPUProfile: function(),
    startGoTrace: function(),
    stopCPUProfile: function(),
    stopGoTrace: function(),
    storageRangeAt: function(),
    testSignCliqueBlock: function(),
    traceBadBlock: function(),
    traceBlock: function(),
    traceBlockByHash: function(),
    traceBlockByNumber: function(),
    traceBlockFromFile: function(),
    traceTransaction: function(),
    verbosity: function(),
    vmodule: function(),
    writeBlockProfile: function(),
    writeMemProfile: function(),
    writeMutexProfile: function()
  },
  eth: {//eth:最重要的
    accounts: ["0x22592dc0a2c474272f364e1b084db58bad0cdd53"],
    blockNumber: 15,
    coinbase: "0x22592dc0a2c474272f364e1b084db58bad0cdd53",
    compile: {
      lll: function(),
      serpent: function(),
      solidity: function()
    },
    defaultAccount: undefined,
    defaultBlock: "latest",
    gasPrice: 1000000000,
    hashrate: 0,
    mining: false,
    pendingTransactions: [],
    protocolVersion: "0x40",
    syncing: false,
    call: function(),
    chainId: function(),
    contract: function(abi),
    estimateGas: function(),
    fillTransaction: function(),
    filter: function(options, callback, filterCreationErrorCallback),
    getAccounts: function(callback),
    getBalance: function(),
    getBlock: function(),
    getBlockByHash: function(),
    getBlockByNumber: function(),
    getBlockNumber: function(callback),
    getBlockTransactionCount: function(),
    getBlockUncleCount: function(),
    getCode: function(),
    getCoinbase: function(callback),
    getCompilers: function(),
    getGasPrice: function(callback),
    getHashrate: function(callback),
    getHeaderByHash: function(),
    getHeaderByNumber: function(),
    getMining: function(callback),
    getPendingTransactions: function(callback),
    getProof: function(),
    getProtocolVersion: function(callback),
    getRawTransaction: function(),
    getRawTransactionFromBlock: function(),
    getStorageAt: function(),
    getSyncing: function(callback),
    getTransaction: function(),
    getTransactionCount: function(),
    getTransactionFromBlock: function(),
    getTransactionReceipt: function(),
    getUncle: function(),
    getWork: function(),
    iban: function(iban),
    icapNamereg: function(),
    isSyncing: function(callback),
    namereg: function(),
    resend: function(),
    sendIBANTransaction: function(),
    sendRawTransaction: function(),
    sendTransaction: function(),
    sign: function(),
    signTransaction: function(),
    submitTransaction: function(),
    submitWork: function()
  },
  ethash: {
    getHashrate: function(),
    getWork: function(),
    submitHashRate: function(),
    submitWork: function()
  },
  isIBAN: undefined,
  miner: {
    getHashrate: function(),
    setEtherbase: function(),
    setExtra: function(),
    setGasPrice: function(),
    setRecommitInterval: function(),
    start: function(),
    stop: function()
  },
  net: {
    listening: true,
    peerCount: 3,
    version: "15",
    getListening: function(callback),
    getPeerCount: function(callback),
    getVersion: function(callback)
  },
  personal: {
    listAccounts: ["0x22592dc0a2c474272f364e1b084db58bad0cdd53"],
    listWallets: [{
        accounts: [...],
        status: "Locked",
        url: "keystore:///usr/local/GethProjects/keystore/UTC--2022-07-12T14-38-52.834936211Z--22592dc0a2c474272f364e1b084db58bad0cdd53"
    }],
    deriveAccount: function(),
    ecRecover: function(),
    getListAccounts: function(callback),
    getListWallets: function(callback),
    importRawKey: function(),
    initializeWallet: function(),
    lockAccount: function(),
    newAccount: function github.com/ethereum/go-ethereum/console.(*bridge).NewAccount-fm(),
    openWallet: function github.com/ethereum/go-ethereum/console.(*bridge).OpenWallet-fm(),
    sendTransaction: function(),
    sign: function github.com/ethereum/go-ethereum/console.(*bridge).Sign-fm(),
    signTransaction: function(),
    unlockAccount: function github.com/ethereum/go-ethereum/console.(*bridge).UnlockAccount-fm(),
    unpair: function()
  },
  providers: {
    HttpProvider: function(host, timeout, user, password),
    IpcProvider: function(path, net)
  },
  rpc: {
    modules: {
      admin: "1.0",
      debug: "1.0",
      eth: "1.0",
      ethash: "1.0",
      miner: "1.0",
      net: "1.0",
      personal: "1.0",
      rpc: "1.0",
      txpool: "1.0",
      web3: "1.0"
    },
    getModules: function(callback)
  },
  settings: {
    defaultAccount: undefined,
    defaultBlock: "latest"
  },
  shh: {//与whisper相关的组件
    addPrivateKey: function(),
    addSymKey: function(),
    deleteKeyPair: function(),
    deleteSymKey: function(),
    generateSymKeyFromPassword: function(),
    getPrivateKey: function(),
    getPublicKey: function(),
    getSymKey: function(),
    hasKeyPair: function(),
    hasSymKey: function(),
    info: function(),
    markTrustedPeer: function(),
    newKeyPair: function(),
    newMessageFilter: function(options, callback, filterCreationErrorCallback),
    newSymKey: function(),
    post: function(),
    setMaxMessageSize: function(),
    setMinPoW: function(),
    version: function()
  },
  txpool: {
    content: {
      pending: {},
      queued: {}
    },
    inspect: {
      pending: {},
      queued: {}
    },
    status: {
      pending: 0,
      queued: 0
    },
    getContent: function(callback),
    getInspect: function(callback),
    getStatus: function(callback)
  },
  version: {
    api: "0.20.1",
    ethereum: "0x40",
    network: "15",
    node: "Geth/v1.9.8-stable-d62e9b28/linux-amd64/go1.13.4",
    whisper: undefined,
    getEthereum: function(callback),
    getNetwork: function(callback),
    getNode: function(callback),
    getWhisper: function(callback)
  },
  BigNumber: function a(e,n),
  createBatch: function(),
  fromAscii: function(str),
  fromDecimal: function(value),
  fromICAP: function(icap),
  fromUtf8: function(str),
  fromWei: function(number, unit),
  isAddress: function(address),
  isChecksumAddress: function(address),
  isConnected: function(),
  padLeft: function(string, chars, sign),
  padRight: function(string, chars, sign),
  reset: function(keepIsSyncing),
  setProvider: function(provider),
  sha3: function(string, options),
  toAscii: function(hex),
  toBigNumber: function(number),
  toChecksumAddress: function(address),
  toDecimal: function(value),
  toHex: function(val),
  toUtf8: function(hex),
  toWei: function(number, unit)
}

 同步回调:会阻塞进程,有顺序保证

 异步回调,序列化:一般web应用都是用异步调用

编译过程:编译sol文件

 --bin生成字节码文件,给以太坊去执行

 --abi生成abi文件,供web3去调用

 node控制台:js的执行环境,编写好的js文件,可以用node直接去运行

 创建一个web3对象(web3是一个名字,随意)

 BigNumber

 s:表示一个符号,表示正负号。整数是1,负数是-1

 e:科学计数法的位数

 c:是一个数组,每14位切割一次,从低位开始切割

web3中:ctrl+L是一键清屏

猜你喜欢

转载自blog.csdn.net/weixin_62775913/article/details/125761571