title: Transaction has been reverted by the EVM - web3 error
body: <p>I have an issue when trying to deploy a smart contract with web3 from a <code>handleClick</code> function.</p>
  <p>This is the error I'm getting:</p>
  <pre><code>Error: Transaction has been reverted by the EVM:
  {
    &quot;blockHash&quot;: &quot;0x5deeb052b68c675d71db1fbe7a5cdcfb4ba5e099cbf21e1c666f306cfc8e1f58&quot;,
    &quot;blockNumber&quot;: 10176288,
    &quot;contractAddress&quot;: &quot;0xBBc84ABa240653B95FF727f92639E2526C24Fcbd&quot;,
    &quot;cumulativeGasUsed&quot;: 5909534,
    &quot;from&quot;: &quot;0x4498f943e0a13d70b28e7565cf4e33bf443e6bf9&quot;,
    &quot;gasUsed&quot;: 139864,
    &quot;logs&quot;: [],
    &quot;logsBloom&quot;: &quot;0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000&quot;,
    &quot;status&quot;: false,
    &quot;to&quot;: null,
    &quot;transactionHash&quot;: &quot;0x1f040610e9165de4fc9ddba259ce5fc6d7e21becd395d40e90f807aa549511f2&quot;,
    &quot;transactionIndex&quot;: 21,
    &quot;type&quot;: &quot;0x0&quot;
  }
  </code></pre>
  <p>My Code:</p>
  <pre><code>  const handleClick = async (e) =&gt; {
      e.preventDefault();
      const EthereumTx = require('ethereumjs-tx').Transaction
      const web3 = new Web3(
        &quot;https://ropsten.infura.io/v3/&lt;private-id&gt;&quot;
      );
      const account1 = &quot;&lt;my-metamask-account-on-ropsten-with-eth&gt;&quot;;
      const privateKey1 = Buffer.from(
          '&lt;private-key&gt;',
          'hex',
        )
  
      web3.eth.getTransactionCount(account1, (err, txCount) =&gt; {
          //Smart contract data
          const contractData = '0x60806040523480156200001157600080fd.....very long'
        // create transaction
      const txParams = {
          nonce: web3.utils.toHex(txCount),
          gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),
          gasLimit: web3.utils.toHex(2000000),// Raise this if needed
          //to: '0x0000000000000000000000000000000000000000',
          data: contractData,
        }
        // The second parameter is not necessary if these values are used
        // sign the transaction
        const tx = new EthereumTx(txParams, { chain: 'ropsten', hardfork: 'petersburg' })
         tx.sign(privateKey1);
    
        const serializedTx = tx.serialize();
        const raw = '0x' + serializedTx.toString('hex')
        
        //broadcast transaction
        web3.eth.sendSignedTransaction(raw, (err, txHash) =&gt; {
          console.log('err', err, 'txHash', txHash)
        })
      });
    }
  </code></pre>
  <p>When I add a <code>to:x000000000000000000000000000</code> under &quot;gas limit&quot;, the tx is a success, but it's not creating a contract.</p>
  <p>The Smart contract from Remix:</p>
  <pre><code>// SPDX-License-Identifier: MIT
  pragma solidity ^0.8.0;
  
  import &quot;@openzeppelin/contracts/token/ERC20/ERC20.sol&quot;;
  
  contract TestToken is ERC20 {
      constructor() ERC20(&quot;WER Token&quot;, &quot;WER&quot;) {
          _mint(msg.sender, 5000000000000000000000000);
      }
  
      function decimals() public view virtual override returns (uint8) {
          return 18;
      }
  }
  </code></pre>
  <p>From <code>truffle.config</code>:</p>
  <pre><code>ropsten: {
    // provider: () =&gt; new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/${infuraApiKey}`),
    network_id: 3, // Ropsten's id
    gas: 5500000, // Ropsten has a lower block limit than mainnet
    // confirmations: 2,    // # of confs to wait between deployments. (default: 0)
    // timeoutBlocks: 200,
    networkCheckTimeout: 99999, // # of blocks before a deployment times out  (minimum/default: 50)
    // skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
  },
  </code></pre>