I have a first contract with some very basic functionality :

contract ContractA {

    uint public supplyA;

    function ContractA (uint _supply) { 
        supplyA = _supply; 

    function setNewSupply() { 
        supplyA = 1000;

I want to create a new instance of this contract from within a second contract :

import './ContractA.sol';

contract ContractB {

    uint public supplyB;

    event LogSupplyA(uint supplyA);

    function ContractB () {
        supplyB = 100;

    function deployA() returns (address) {
        ContractA newContract = new ContractA(250);


        return newContract;

When I run the deployA() function on contractB in Remix, it returns an address for a contractA instance. However, if I use that address to look at that instance afterwards it cannot be found

TypeError: Cannot read property 'op' of undefined

Omitting the following lines solves the problem:


But leaving the lines in does make the LogSupplyA event display 1000 as value instead of 250, and does return an address for my new instance.

I don't fully understand what is happening here. Why is an updated value shown in my event and is an address returned for my new contract instance, if apparently something went wrong and my contract was not instantiated?

Your Answer

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

Browse other questions tagged or ask your own question.