Skip to main content
Add formatting for future viewers
Source Link
Shane Fontaine
  • 18.4k
  • 20
  • 57
  • 83

Contract code:

contract RecordStore{ struct Record { string value; address owner; } mapping(string => Record) records; Record lastRecord; function addRecord(string _recordId, string _value, address _owner) returns (bool) { Record r = records[_recordId]; r.value = _value; r.owner = _owner; lastRecord = r; return true; } function getLastRecordOwner() returns (addr) { return lastRecord.owner; } } 

Client code:

 var rs = RecordStore.deployed(); var account = web3.eth.getAccounts()[0]; var recordName = "test_name"; rs.addRecord(recordName, account, recordName, account, {from:account}).then(function(res) { rs.getLastRecordOwner.call().then(function(lastRecord) { console.log("last record owner: " + lastRecord); }); }); 

When I run the test on testrpc everything works as expected. But when I run it on geth lastRecordlastRecord is null. Does anyone know why?

Contract code:

contract RecordStore{ struct Record { string value; address owner; } mapping(string => Record) records; Record lastRecord; function addRecord(string _recordId, string _value, address _owner) returns (bool) { Record r = records[_recordId]; r.value = _value; r.owner = _owner; lastRecord = r; return true; } function getLastRecordOwner() returns (addr) { return lastRecord.owner; } } 

Client code:

 var rs = RecordStore.deployed(); var account = web3.eth.getAccounts()[0]; var recordName = "test_name"; rs.addRecord(recordName, account, recordName, account, {from:account}).then(function(res) { rs.getLastRecordOwner.call().then(function(lastRecord) { console.log("last record owner: " + lastRecord); }); }); 

When I run the test on testrpc everything works as expected. But when I run it on geth lastRecord is null. Does anyone know why?

Contract code:

contract RecordStore{ struct Record { string value; address owner; } mapping(string => Record) records; Record lastRecord; function addRecord(string _recordId, string _value, address _owner) returns (bool) { Record r = records[_recordId]; r.value = _value; r.owner = _owner; lastRecord = r; return true; } function getLastRecordOwner() returns (addr) { return lastRecord.owner; } } 

Client code:

 var rs = RecordStore.deployed(); var account = web3.eth.getAccounts()[0]; var recordName = "test_name"; rs.addRecord(recordName, account, recordName, account, {from:account}).then(function(res) { rs.getLastRecordOwner.call().then(function(lastRecord) { console.log("last record owner: " + lastRecord); }); }); 

When I run the test on testrpc everything works as expected. But when I run it on geth lastRecord is null. Does anyone know why?

added 406 characters in body
Source Link
etang
  • 121
  • 4

Contract code:

contract RecordStore{ struct Record { string value; address owner; } mapping(string => Record) records; Record lastRecord; function addRecord(string _recordId, string _value, address _owner) returns (bool) { Record r = records[_recordId]; r.value = _value; r.owner = _owner; lastRecord = r; return true; } function getLastRecordOwner() returns (addr) { return lastRecord.owner; } } 

Does anyone know why getLastRecordOwner() returns zero? For some reason, it works fine inClient code:

 var rs = RecordStore.deployed(); var account = web3.eth.getAccounts()[0]; var recordName = "test_name"; rs.addRecord(recordName, account, recordName, account, {from:account}).then(function(res) { rs.getLastRecordOwner.call().then(function(lastRecord) { console.log("last record owner: " + lastRecord); }); }); 

When I run the test on testrpc, but breaks everything works as expected. But when I run it on my local geth lastRecord is null. (haven't tested with testnet yet) Does anyone know why?

contract { struct Record { string value; address owner; } mapping(string => Record) records; Record lastRecord; function addRecord(string _recordId, string _value, address _owner) returns (bool) { Record r = records[_recordId]; r.value = _value; r.owner = _owner; lastRecord = r; return true; } function getLastRecordOwner() returns (addr) { return lastRecord.owner; } } 

Does anyone know why getLastRecordOwner() returns zero? For some reason, it works fine in testrpc, but breaks on my local geth. (haven't tested with testnet yet)

Contract code:

contract RecordStore{ struct Record { string value; address owner; } mapping(string => Record) records; Record lastRecord; function addRecord(string _recordId, string _value, address _owner) returns (bool) { Record r = records[_recordId]; r.value = _value; r.owner = _owner; lastRecord = r; return true; } function getLastRecordOwner() returns (addr) { return lastRecord.owner; } } 

Client code:

 var rs = RecordStore.deployed(); var account = web3.eth.getAccounts()[0]; var recordName = "test_name"; rs.addRecord(recordName, account, recordName, account, {from:account}).then(function(res) { rs.getLastRecordOwner.call().then(function(lastRecord) { console.log("last record owner: " + lastRecord); }); }); 

When I run the test on testrpc everything works as expected. But when I run it on geth lastRecord is null. Does anyone know why?

edited title
Link
etang
  • 121
  • 4

Solidity multiple variables returnsassignment ends up with null

added 108 characters in body
Source Link
etang
  • 121
  • 4
Loading
Source Link
etang
  • 121
  • 4
Loading