I have the following solidity code, to get the data that has been mapped to an address,

function showOrg(address org) external view returns(uint identifier, string memory organization_name, bool ActivityStatus, string memory Classifier, string memory Address, string memory DomiciledIn, bool Status){
    require(orgs[org].admins[msg.sender] == true, "You are not authorized to view this data!");
    return(orgs[org].identifier, orgs[org].organization_name, orgs[org].ActivityStatus, orgs[org].Classifier, orgs[org].Address, orgs[org].DomiciledIn, orgs[org].Status);

I am calling it from Web3 as follows,

  .send({from: contractAddress}).then(function(receipt){

However, it does not seem to return the data that I am expecting, which is the 'organization_name' and so on. How can I get this data or is there something wrong with my approach here?

What I get is something like this,

{transactionHash: "0x5abceb4c507779b7d9ed89294358389174f4a1b6e254e14b7745dc480b48aaba", transactionIndex: 0, blockHash: "0xd40bbe210fd94ff79bcd7e7e14ce28612a00ab40fa420c40dd2ed5515d195ac1", blockNumber: 44, from: "0xf7642c725fa20c2ff18befbf7351b5fb94077ef9", …}

What am I doing wrong? As additional information, given below is my Solidity function for adding data,

function addOrg(address org, uint _identifier, string calldata _organization_name, bool _ActivityStatus, string calldata _Classifier, string calldata _Address, string calldata _DomiciledIn, bool _Status) external{
    Org storage organization = orgs[org];
    organization.identifier = _identifier;
    organization.organization_name = _organization_name;
    organization.ActivityStatus = _ActivityStatus;
    organization.Classifier = _Classifier;
    organization.Address = _Address;
    organization.DomiciledIn = _DomiciledIn;
    organization.Status = _Status;
    organization.admins[msg.sender] = true;
function showOrg(address org) external view

showOrg() has the type view that means only reads/return data without writing data into the contract/blockchain. So (view) does not change anything on the contract but when you are calling that function using web3, you need to use the call() method.


check the example and the tutorial..



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.