Guest User

Untitled

a guest
May 17th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. web3.eth.estimateGas({data: '0x' + bytecode}).then(value=>{
  2. console.log('gasEstimate = ' + value);
  3. let MyContract = new web3.eth.Contract(abi,{
  4. from: publicKey,//user wallet
  5. gasPrice: '10000000000000',
  6. gas: value
  7. });
  8. console.log('deploying contract...');
  9. MyContract.deploy().send(function(error, transactionHash){
  10. }).on('error', function(error){ })
  11. .on('transactionHash', function(transactionHash){ })
  12. .on('receipt', function(receipt){
  13. console.log(receipt.contractAddress) // contains the new contract address })
  14. .on('confirmation', function(confirmationNumber, receipt){ })
  15. .then(function(newContractInstance){
  16. console.log(newContractInstance.options.address) // instance with the new contract address
  17. });
  18. });
  19.  
  20. UnhandledPromiseRejectionWarning: Error: Request failed with status code 522
  21. at createError (/home/project/node_modules/axios/lib/core/createError.js:16:15)
  22. at settle (/home/project/node_modules/axios/lib/core/settle.js:18:12)
  23. at IncomingMessage.handleStreamEnd (/home/project/node_modules/axios/lib/adapters/http.js:201:11)
  24. at emitNone (events.js:111:20)
  25. at IncomingMessage.emit (events.js:208:7)
  26. at endReadableNT (_stream_readable.js:1064:12)
  27. at _combinedTickCallback (internal/process/next_tick.js:138:11)
  28. at process._tickCallback (internal/process/next_tick.js:180:9)
  29. (node:13887) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
  30. (node:13887) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  31.  
  32. myContract.deploy({
  33. data: '0x12345...',
  34. arguments: [123, 'My String']
  35. })
  36. .send({
  37. from: '0x1234567890123456789012345678901234567891',
  38. gas: 1500000,
  39. gasPrice: '30000000000000'
  40. }, function(error, transactionHash){ ... })
  41. .on('error', function(error){ ... })
  42. .on('transactionHash', function(transactionHash){ ... })
  43. .on('receipt', function(receipt){
  44. console.log(receipt.contractAddress) // contains the new contract address
  45. })
  46. .on('confirmation', function(confirmationNumber, receipt){ ... })
  47. .then(function(newContractInstance){
  48. console.log(newContractInstance.options.address) // instance with the new contract address
  49. });
Add Comment
Please, Sign In to add comment