0

I am able to test with truffle and successfully assert that the values of my deployed contract are correct, but in both testrpc and a private geth the actual values in my contract are empty.

I initialize my contract early on

this.contract = this.web3.eth.contract(this.abi);

then later via the GUI is create a new Contract:

this.deployedContract = this.contract.new(name, {from: contractAddress, gas: 3000000, data: this.byteCode}, (contractError, contractResult) => {
    if (!contractError && contractResult) {
        console.log('contract address: ' + contractResult.address);
        console.log('contractResult: ' + contractResult);
    }else if(contractError){
        console.log("contractError: " + contractError);
    }
});

The contract is mined and I receive an address that I lookup. In both the geth console and via the JavaScript API I see the result of name = 0x0000000000000000000000000000000000000000000000000000000000000000

name is bytes32

In the geth console I lookup the transaction and see that cumulativeGasUsed: 1109932 which is less that the 3000000 I declared upfront.

I also notice that the gas was not taken off my account.

  • have you tested your contract using remix? – Luiz Soares Nov 28 '17 at 10:31
  • Yes, works perfectly if I use the JavaScript VM or the Web3 Provider to my Private Geth running locally. – Phillip Gibb Nov 28 '17 at 12:53
0

It would seem that if you have a Contract that accepts arguments into it's parameters, if you do not match the two together then the contract will be created as if with an empty constructor (default?), without any errors or warnings.

So in my case, my contract had one constructor that accepted name and lastname, I only supplied name. bingo, empty contract.

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.