I have this contract called Registry
pragma solidity ^0.4.11;
contract Registry {
mapping(bytes32 => address) public ID;
mapping(address => address) public Contract;
function register(bytes32 _id) {
ID[_id] = tx.origin;
Contract[tx.origin] = msg.sender;
}
function getPublicAddress(bytes32 _id) constant returns (address) {
return (ID[_id]);
}
function getContractAddress(bytes32 _id) constant returns (address) {
return Contract[ID[_id]];
}
}
and another called User
contract User {
address owner;
address reg;
Registry registry = Registry(reg);
// Register in the system
function register(bytes32 _id) {
registry.register(_id);
}
function getContractAddress(bytes32 _id) {
registry.getContractAddress(_id);
}
function getPublicAddress(bytes32 _id) {
registry.getPublicAddress(_id);
}
}
The registry(), getPublicAddress(), and getContractAddress() are not working and I can't understand why.
I tried testing with Truffle but ran into a known bug which is unsolved as of now. I asked about it here, the discussion on GitHub is here.
I tried running it in my private blockchain, where I have the following code
register: function(publicAddress, contractAddress, _id) {
// Getting that user's instance of the contract
const contract = contractInstance("User", contractAddress);
// Interaction with the contract
contract.register(web3.fromAscii(_id), {from: publicAddress}, (err, res) => {
// Log transaction to explore
if (err) {
console.log(err);
} else {
console.log('tx: ' + res);
helpers.addTransaction(publicAddress, res);
}
});
},
getContractAddress: function(contractAddress, _id) {
const contract = contractInstance("User", contractAddress);
contract.getContractAddress.call(web3.fromAscii(_id), (err, res) => {
if (err) {
console.log(err);
} else {
console.log(res);
}
})
},
getPublicAddress: function(contractAddress, _id) {
const contract = contractInstance("User", contractAddress);
contract.getPublicAddress.call(web3.fromAscii(_id), (err, res) => {
if (err) {
console.log(err);
} else {
console.log(res);
}
})
}
After registering (and mining) I simply get back
[]
when calling getPublicAddress()or getContractAddress().
Can anyone see where the problem is?

bytes32parametersgetPublicAddressandgetContractAddressfunctions? – Lee Aug 22 '17 at 22:42