This is a sequence of another question I asked.
I have the following contract
contract User {
string publicKey;
function setPublicKey(string _publicKey)
onlyOwner
{
publicKey = _publicKey;
}
function getPublicKey() returns (string _publicKey) {
return publicKey;
}
}
I have set the string to be
5030480389847504049639477069961901518251822532055915812015454717740961852942027334498786032153069913846973579859702642411497486328669598344496363306620763652362226170692287240855050713537819594000868803228735504934019483458523068727831434237837325563417285328158635879852481735301070609988900677951635437637299660610442447448957534545817
I called the setPublicKey()
method with the string value and got back the transaction hash 0x789894f0b5a85cc45e317cb51af27a4d28858e3b64c64ee00118f4543d7a5de7
(it's a private chain).
I then called getPublicKey()
but just got back an empty reply. Why does this happen?
This seems to be pretty basic but I've googled and checked here and didn't find any information that could answer it.
EDIT: Adding getPublicKey()
function
// Example calling function
function getPublicKey(publicAddress, contractAddress, contractName) {
// Get the contract code from contracts
const input = fs.readFileSync('contracts/' + contractName + '.sol').toString();
const output = solc.compile(input);
// The trailing ':' is needed otherwise it crashes
const bytecode = output.contracts[':' + contractName].bytecode;
const abi = JSON.parse(output.contracts[':' + contractName].interface);
const contract = web3.eth.contract(abi).at(contractAddress);
contract.getPublicKey.call((err, res) => {
if (err) {
console.log(err);
} else {
console.log("Public Key is ");
console.log(res);
}
})
}
It's a function in my node app.