2

I have created a contract with functions...the get() is used for storing and getarray is for returning values...

struct arrayy{
    uint256[] arrayvalue;
}
mapping(address => arrayy) arraymapping;

event logg(
    uint256 z,
    address sender
);

function get(uint256 y, address _owner) internal{
   arraymapping[_owner].arrayvalue.push(y);
   emit logg(y,_owner);
}

function getarray(address _owner) internal returns(uint256[]){

    return(arraymapping[_owner].arrayvalue);
}

Then I deployed the contract, and tried to call the get() function by using...

DeployedContractAddress.call(bytes4(keccak256("get(uint256,address)")),1234,0xfffff);

The value is stored because, When I tried to call the getarray() function the value is returned...

But the emit() is not working...

Why this emit() is not working? Help me to resolve this issue? Help will be appreciated...

  • Which version of solidity your using? – Jitendra Kumar. Balla Jul 19 '18 at 10:31
  • Truffle v4.1.5 (core: 4.1.5) Solidity v0.4.21 (solc-js) – lekshmi Jul 19 '18 at 10:49
  • "in logs it is not printing anything" - please post relevant off-chain code. – goodvibration Jul 19 '18 at 11:24
  • {"tx":"0x82be221c18a5fd696f86435ce233793cd0c9f781e62d1782a2469d03d9be7ba9","receipt":{"blockHash":"0x89dba24d238b3f050308477c182eb3c9f68b3977dff36eed471e389248bd7c83","blockNumber":76566,"contractAddress":null,"cumulativeGasUsed":4000000,"from":"","gasUsed":4000000,"logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000","root":"0x3b71fe05e0ca0c5a90b92570e7a30764efd65522","to":"0x849610fc991e28a70bc65475fd7b0e00da42f173","transactionHash":"0x82be221c18a5fd696f86435ce233793cd0c9f781e62d1782a2469d03d9be7ba9","transactionIndex":0},"logs":[]} – lekshmi Jul 19 '18 at 11:57
3

As pr your code I can see there is a issue in access specifier. There is no issue in emit()

function get(uint256 y, address _owner) internal{
   arraymapping[_owner].arrayvalue.push(y);
   emit logg(y,_owner);
}

As per solidity document, you can invoke/call internal method's with in the contract and child contract. You can't access out side your contract.

Instead of internal use public or external, so that you can access outside of contract.

function get(uint256 y, address _owner) public{
   arraymapping[_owner].arrayvalue.push(y);
   emit logg(y,_owner);
}
| improve this answer | |
  • 1
    Yes I changed the code....But when I tried to call the function...uisng below equation... DeployedContractAddress.call(bytes4(keccak256("get(uint256,address)")),1234,0xfffff); still the log is not getting... – lekshmi Jul 20 '18 at 11:28
  • Same issue for me...When using DeployedContractAddress.call(bytes4(keccak256("get(uint256,address)")),1234,0xfffff); logs are not displayed. ie; when function is called by deployed address, logs are displayed. But when I tried to call function from other wallet address,its not working...Is it not possible? – angelmaria Jul 23 '18 at 5:39

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.