question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot convert undefined or null to object when deploying to testnet

See original GitHub issue
  • I’ve asked for help in the Truffle Gitter before filing this issue.

Issue

I keep getting an error when trying to run truffle migrate.

Steps to Reproduce

Create a project directory called my-project Ensure truffle is installed Type in “truffle init” in the terminal while in the my-project directory cd contracts git clone https://github.com/OpenZeppelin/openzeppelin-solidity.git Create a file called Example.sol Paste the following code into the Example.sol file.

pragma solidity ^0.5.0;
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
contract ExampleToken is ERC20, ERC20Detailed {
    uint private INITIAL_SUPPLY = 10000e18;
    constructor () public
        ERC20Detailed("ExampleToken", "EGT", 18)
    {
        _mint(msg.sender, INITIAL_SUPPLY);
    }
}

cd … # To get into the parent directory create a file called secrets.json and paste the following into it { “mnemonic”: “x x x x x x x x x x x x” } Ensure that the mnemonic matches the mnemonic from the local instance of geth.

npm init npm install --save web3 npm install --save truffle-hdwallet-provider modify truffle.js to match the following…

var secrets = require("./secrets.json");
var HDWalletProvider = require("truffle-hdwallet-provider");
var Web3 = require('web3'); // Set variable to the web3 module
var web3 = new Web3(Web3.givenProvider || "ws://localhost:8545");

module.exports = {
    // See <http://truffleframework.com/docs/advanced/configuration>
    // to customize your Truffle configuration!
    networks: {
        development: {
            host: "127.0.0.1",
            port: 8545,
            network_id: "*", // Match any network id
            gas: 10000000,
            gasLimit: 26000000000
        },
        ropsten: {
            provider: new HDWalletProvider(secrets.mnemonic, "https://ropsten.infura.io/"),
            network_id: "*",
            gas: 1000000,
            gasLimit: 67000000,
            gasPrice: 20000000000
        },
        // network_id: 3,
        // host: "localhost",
        // port:  8545,
        // gas:   2900000
        mainnet: {
            provider: new HDWalletProvider(secrets.mnemonic, "https://mainnet.infura.io/"),
            network_id: 1,
            gas: 1000000,
            gasLimit: 67000000
        }
    },
    compilers: {
        solc: {
            version: "0.5.2"
        }
    }
};

In 1_initial_migration.js file in migrations folder:

module.exports = function(deployer) {
};

In 2_deploy_contracts.js file remove all the code:

module.exports = function(deployer) {
};

type in truffle migrate --network ropsten into terminal

Expected Behavior

For no contracts to be deployed, but for no errors to be thrown either.

Actual Results

I get the following message in terminal: TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>) at supplier.load.then.solc (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/index.js:184:1) at <anonymous> Truffle v5.0.5 (core: 5.0.5) Node v8.11.1

Environment

  • Operating System: Version 10.14.2
  • Ethereum client: Version: 1.8.5-unstable
  • Truffle version (truffle version): Truffle v5.0.5 (core: 5.0.5)
  • node version (node --version): Node v8.11.1
  • npm version (npm --version): 5.6.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
haltman-atcommented, Feb 9, 2022

Closing this again for issue maintenance; if anyone is still having this issue, I would suggest opening a new one. Thanks!

1reaction
dblockunitycommented, Mar 13, 2019

I followed the steps listed in this bug report and what I found was that the migration worked when I reproduced the problem. When creating the report I had to create an environment that matched my proprietary codebase, but the new environment gives different results.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot convert undefined or null to object - Stack Overflow
Generic answer. This error is caused when you call a function that expects an Object as its argument, but pass undefined or null...
Read more >
Cannot convert undefined or null to object - Contracts
i get to the 'Deploy the contract' and when i click deploy i get the below message? Hi @Triston_Edwards,
Read more >
Initializing search - Truffle Suite
React Native is missing some of the global objects that are available on ... throw new TypeError('Cannot convert undefined or null to object');...
Read more >
Cannot convert undefined or null to object after compile
I can compile using solc 0.7.5 and npx oz compile . token.sol : //SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.5; ...
Read more >
ethereum/remix - Gitter
... to deploy the smart contract - its giving the error in console saying "creation of SampleMapping errored: Cannot convert undefined or null...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found