I'm running into this compiler error when I compile my solidity code:

error[3419]: TypeError: Cannot call function via contract type name.

Here is my code:

import "MyContract.sol";
MyContract myContract = new MyContract();
address contractAddress = MyContract.deployContract("SimpleStorage");

What's going on?

MyContract is another contract.

1 Answer 1


You have to call a function on an instantiation and not the contract class itself.

Change address contractAddress = MyContract.deployContract("SimpleStorage"); -> address contractAddress = myContract.deployContract("SimpleStorage");

You want to use the variable name, not the class name.

For me, it was as simple as changing the case since the names were so similar:




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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