web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Encoding of uninitalized string property of a contract failed

Open nazarhussain opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

For a contract which have a string property but not intialized, the returning value cause an encoding error.

AbiError: Parameter decoding error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.

Expected Behavior

Such scenario should return into empty string.

Steps to Reproduce

The solidity contract.

contract MyContract {
	string private myAttribute;

	function getAttr() public view returns (string memory) {
		return myAttribute;
	}
}

The web3 code.

let contract = new Contract(MyContractAbi);
contract = await contract.deploy().send(....);

await contract.methods.getAttr().call();

The following scenario can also be reproduced with Greeter.sol contract we have.

Web3.js Version

4.x

Environment

No response

Anything Else?

No response

nazarhussain avatar May 30 '22 18:05 nazarhussain

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Jul 30 '22 00:07 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Oct 25 '22 00:10 github-actions[bot]