web3.js
web3.js copied to clipboard
Encoding of uninitalized string property of a contract failed
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
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.
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.