Contract-Deployment

交易確認過程中超時。請注意,交易仍然可以得到確認

  • April 30, 2019

合約部署,web3 版本為 1.0.0-beta.52。

let {bytecode, interface} = require('./1-compile')

let Web3 = require('web3')

let web3 = new Web3('http://localhost:7545')

console.log('version :', web3.version)

const account = '0xdf9c60D4F6E92c977f220dc507eDAfaEDF026c1c'

let contract = new web3.eth.Contract(JSON.parse(interface))

contract.deploy({
   data: '0x'+bytecode, 
   arguments: ['hello world'] 
}).send({
   from: account,
   gas : '500000',
   gasPrice: '1',
}).then((instance) => {
   console.log('address: ', instance.options.address)
}).catch(err =>{
   console.log('err : ', err)
})

當我執行時node xx.js,控制台會輸出這樣的文本。我該如何解決。

version : 1.0.0-beta.52
err :  { error:
  Error: Timeout exceeded during the transaction confirmation process. Be aware the transaction could still get confirmed!
      at _callee2$ (/Users/xx/Desktop/blockchain/workspace/my-dapp/node_modules/web3-core-method/dist/web3-core-method.cjs.js:418:36)
      at tryCatch (/Users/xx/Desktop/blockchain/workspace/my-dapp/node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (/Users/xx/Desktop/blockchain/workspace/my-dapp/node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (/Users/xx/Desktop/blockchain/workspace/my-dapp/node_modules/regenerator-runtime/runtime.js:97:21)
      at asyncGeneratorStep (/Users/xx/Desktop/blockchain/workspace/my-dapp/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (/Users/xx/Desktop/blockchain/workspace/my-dapp/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at process._tickCallback (internal/process/next_tick.js:68:7),
 receipt:
  { transactionHash:
     '0xcb9122b4897ec6714938b475c47e6a5fc9d71bdc3efb850251285bcbc27dcf95',
    transactionIndex: 0,
    blockHash:
     '0xeaa09735ef6226fc103b64d82d13d48dac60f3d927f9b9941ac151ebe8e12afa',
    blockNumber: 1,
    from: '0xdf9c60d4f6e92c977f220dc507edafaedf026c1c',
    to: null,
    gasUsed: 267772,
    cumulativeGasUsed: 267772,
    contractAddress: '0x1c6B7774F8c77daad698B764b853cBfEDBa54fcd',
    logs: [],
    status: true,
    logsBloom:
     '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    v: '0x1c',
    r:
     '0x696a6859397be535077e9848e5d8aef6116d907f56d4d21e36160e4b639ac9ff',
    s:
     '0x333862057233193fe9ba3da9ce63b2f77203f07ecc832b50e3222092622caca5' },
 confirmations: 1,
 confirmationChecks: 750 }

https://ethereum.stackexchange.com/a/70253/53458 我在這個網址中找到了答案。我複制程式碼

const OPTIONS = {
   defaultBlock :"latest",
   transactionConfirmationBlocks: 1,
   transactionBlockTimeout: 5
}

let Web3 = require('web3')

let web3 = new Web3('http://localhost:7545', null, OPTIONS)

引用自:https://ethereum.stackexchange.com/questions/70228