0

I have a simple setter and getter for address[] type array in a contract.

I deployed the contracts on testrpc using truffle.

Then in truffle console:

truffle(development)>

lot.addNewUserToLottery(24,0xf392261711006934215e47025275f98b3c156568, {value:50000})

Returns:

{ tx: '0x5ed462b5f80578609223827cc9dea8a51ef2e6920f197734ce6c64b0cbebf372',
  receipt:
   { transactionHash: '0x5ed462b5f80578609223827cc9dea8a51ef2e6920f197734ce6c64b0cbebf372',
     transactionIndex: 0,
     blockHash: '0x4015c50e9a5721466c007cade050671cb8fa3b768295a1793e0683e8613e4aa9',
     blockNumber: 459,
     gasUsed: 74162,
     cumulativeGasUsed: 74162,
     contractAddress: null,
     logs: [ [Object] ],
     status: '0x01',
     logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' },
  logs: [] }

But when i call the getter:

truffle(development)> lot.getUserAddress(24,0);

I get the address :

'0xf3922617110067aaf6e0168134a72bed00000000'

Similarly for other addresses stored:

0x83bf9513ceaa869a6b1e847f4f0caa47dc1441b4

returns

0x83bf9513ceaa85b568c5a6858ba4640700000000

Why is the address' second half being changed by solidity?

2

I figured it out, it was a very lame mistake.

I was calling function from truffle console like:

lot.addNewUserToLottery(24,0xf392261711006934215e47025275f98b3c156568, {value:50000})

When one should be using single quotes around address :

lot.addNewUserToLottery(24,'0xf392261711006934215e47025275f98b3c156568', {value:50000})

EVM was accepting the parameter but was changing the address.

Hope someone doesn't make it and if does then find this helpful.

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.