When I add new contract (testrpc) with truffle with parameter of type "address" the reading value of this property seems wrong (always 0x0000000000000000000000000000000000000000), I do not find the cause of the problem

The Demo.sol contract:

pragma solidity ^0.4.2;

contract Demo
     address public test;
     function Demo(address test) payable
        test = test;

I add the new contract with truffle

Demo.new("0x9e99b1aaa2114fdae97c9ab2f20863dfde4659bd", {
    from: account,
    value: web3.toWei(0.1, 'ether')
}).then(function (instance) {
    return instance.test.call({from: account});
}).then(function(test) {

The expected result is 0x9e...9bd but the output is 0x00...000.

If necessary, I push the demo project on Github, Thank you for your help

  • Where did account come from? Is it defined? Consider dropping it and things should default to first account. – Rob Hitchens Apr 17 '17 at 1:38
  • I use web3.eth.getAccounts... and Metamask opens well to ask for confirmation – vincentLg Apr 17 '17 at 8:39

I answer to myself... there was a stupid error in the smart contract... The class variable and the parameter had the same name

This code works :

 address public myaddress;
 function Demo(address test) payable
    myaddress = test;
| improve this answer | |

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.