[Ethereum] How to call a function and to read return values from an external deployed contract address

abicontract-developmentraw-transactionsolidity

I am trying to call a function from deployed contract address using the below format

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

But when trying to call the get(_address) using deployed contract address(without abi encoded), it should return an array. But here, it returns Boolean values true or false.

 function get(address _address) public returns (uint256[]){
 for(uint i=0;i<n;i++){
     arr[address].push(i);
 }
 return (arr);
}

Is there any simple way to get an array values without using ABI encoded?

Best Answer

According to the Solidity documentation, starting from version 0.5.0 it is possible to access the return data from a call:

address.call(bytes memory) returns (bool, bytes memory)

issue low-level CALL with the given payload, returns success condition and return data, forwards all available gas, adjustable

The data is given as a single bytes array, so you will likely want to decode it using abi.decode in order to make use of it.

Prior to version 0.5.0, you can count on the fact that the return values remains on the stack when the call() returns. They can be accessed, but you will have to use assembly.

Related Topic