1

I'm deploying smart contract into a private Ethereum network by web3js and the web3 provider is a Geth node. According to the deployment code, NodeJS should log the deployed contract address on the console (Windows PowerShell), But nothing occurred on it. I don't know what the wrong is. I need a solution to log contract deployment on the console.

The deployment code in NodeJS:

const Web3=require("web3");
const fs=require("fs");
const web3=new Web3(new Web3.providers.WebsocketProvider("ws://<Geth ip in the private network>:<port>"));
      web3.eth.personal.unlockAccount(<sender address>,<password>,300);
const contractJson=".../contract.json";
const contractObj=JSON.parse(fs.readFileSync(contractJsonInterface));
const contractBytecode=`...`;
const contract=new web3.eth.Contract(contractObj.abi,null,{data:contractBytecode});
      contract.deploy().send({from:<sender address>}).then((ins)=>{console.log("Contract mined at "+ins.options.address);});

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.