I'm trying to deploy a very simple smart contract on Ropsten through Infura When I launch (on Ubuntu) my deploy.js script, everything seems to work except I don't get the contractAddress in the receipt The deployment of the same smart contract works fine on Remix, and I'm using the same account I'm getting the bin assembly from Remix or solcjs on the same machine

Pretty frustrating...

nicola@geth2:~/ethnow$ node deploy.js 
(node:4348) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
{ blockHash:
  blockNumber: 7454336,
  contractAddress: null,
  cumulativeGasUsed: 25796,
  from: '0x4f73dc0aafbfab1151b5823a66736a8f46fa49e6',
  gasUsed: 25796,
  logs: [],
  status: true,
  to: '0x0000000000000000000000000000000000000000',
  transactionIndex: 0 }

Smart comntract:

pragma solidity ^0.6.0;

contract SimpleStorage {
    uint storedData;

    event Set(
        address indexed _from,
        uint _storedData

    function set(uint x) public {
        storedData = x;
        emit Set(msg.sender, storedData);

    function get() public view returns (uint) {
        return storedData;

Deploy script

var Web3 = require('web3');
var Tx = require('ethereumjs-tx');
//const fs = require('fs');
//const solc = require('solc');

//var web3 = new Web3(new Web3.providers.WebsocketProvider('wss://:[email protected]/ws/v3/1ef4898b08a84c3b98c755cd48476b92'));

var web3 = new Web3(new Web3.providers.HttpProvider('https://:[email protected]/v3/1ef4898b08a84c3b98c755cd48476b92'));

var privateKey = new Buffer('-----------------', 'hex');

//var abi = [{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","nam$


_nonce = web3.utils.toHex(res);


var rawTx = {
  from: "0x4f73Dc0AAFbFAb1151B5823a66736A8F46Fa49E6",
  nonce: web3.utils.toHex(_nonce),
  gasLimit: web3.utils.toHex(3000000),
  gasPrice: web3.utils.toHex(20000000000),
  to: '0x0000000000000000000000000000000000000000',
  value: '0x00',
  data: '0x608060405234801561001057600080fd5b50610117806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806360fe47b11460375780636d4ce63c146062575b600080fd5b606$
  chainId: web3.utils.toHex(3)

var tx = new Tx(rawTx);

var serializedTx = tx.serialize();

web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('transactionHash', console.log)
.on('receipt', function(err, res){console.log(res); console.log(err)})
.on('error', console.log);

  • Thank you for publishing project ID 1ef4898b08a84c3b98c755cd48476b92. Commented Mar 4, 2020 at 18:26
  • There's nothing in it...
    – Nicola
    Commented Mar 4, 2020 at 18:31
  • I think a got the answer anyway, you need to use null as the target address for the transaction, not 0x0
    – Nicola
    Commented Mar 4, 2020 at 18:34
  • Other people will use it, and you'll get rate-limit apply on your account even though it wasn't you who used it. Commented Mar 4, 2020 at 20:02
  • And you can simply omit the to field from the rawTx object. Commented Mar 4, 2020 at 20:03

1 Answer 1


I think you need to remove to in rawTx.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.