pragma solidity ^0.7.0; // SPDX-License-Identifier: MIT contract TheContract { // Some contract-specific data. struct Loan { bytes cparty; uint32 amount; } Loan loan; // "autoconstructed" constructor(bytes memory cparty, uint32 amount) { loan.cparty = cparty; loan.amount = amount; } /* Things that generate state change cannot return data. They only return * a TransactionReceipt object. Only view or pure functions will be * wrapped with nice type specific return values. Even if you declare * this function to return something, it is IGNORED in the Java wrapper. * You will NOT get * the types back in the Java-wrapped function; you have to wait until the * state change is committed to the block and then you can ask for the data * with a view scoped function. */ function changeCounterparty(string calldata newCpty) public { loan.cparty = bytes(newCpty); } // Returning a string instead of bytes means in Java you get a String // instead of byte[] which is friendlier. function getCounterparty() public view returns (string memory) { return string(loan.cparty); } // An example of a function that returns two types function getInfo() public view returns (bytes memory, uint amount) { return (loan.cparty, loan.amount); } // structs e.g. Loan are internal to contracts. You can pass and receive // structs from an internal function, but you cannot do so to the outside // world i.e. there is no Java wrapper for Loan. }