Closed seedskys closed 6 years ago
Maybe wait until the contract is indeed valid?
@fcorneli what's the problem with it ? I have waitted for 10+ blocks.
the problem has been solved。 I built a wrong contract。
Web3j 3.4.0
public void deploy() throws Exception { log.info("Deploying smart contract"); String greetMessage = "Hi this is a greeter app"; gasPrice=BigInteger.valueOf(100);
this.contract = Greeter.deploy(web3j, credentials, gasPrice, gasLimit, greetMessage).send();
log.info("contract deployed " );
String gr = this.contract.greet().send(); } works fine. however log.info("loading contract"); this.contract = (Greeter) Greeter.load( this.contactAddress, web3j, credentials, gasPrice, gasLimit); String gr = this.contract.greet().send(); always return the above error. Eventhough the contract binary returned from both contract are the same. This is reproducible from many ethereum networks
this.contract = (Greeter) Greeter.load( this.contractAddress, web3jAdmin, credentials, gasPrice, gasLimit); log.info("isContractValid=" + contract.isValid()); while the contract returned from deploy worked just fine, the loaded contract always has contract.isValid() false, isContractValid=false the String gr = this.contract.greet().send(); always through the following exceptions: I have tried a variety of ethereum testnet and local private networks, single or multiple. It must be a bug. Please fix it. Exception in thread "main" org.web3j.tx.exceptions.ContractCallException: Empty value (0x) returned from contract at org.web3j.tx.Contract.executeCallSingleValueReturn(Contract.java:230) at org.web3j.tx.Contract.lambda$executeRemoteCallSingleValueReturn$1(Contract.java:297) at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:30)
i got the same error with glomarch
Don't know if it can help out, but I had the same issue and in my wrapped compiled solidity script, it was :
private static final String BINARY = "[{\"constant\":true,\"inputs\":[],\"name\":\"chars\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}, ( ... )se,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]";
instead of :
private static final String BINARY = "608060405234801561001057600080fd5b5060008054600160a060020a0319163317815560015561027f806100356000 (...) ffffffffffffffffffff163314156102515760005473ffffffffffffffffffffffffffffffffffffffff16ff5b5600a165627a7a72305820545e60010ee0d4b8f1315f9743499c370f058e1ab280aab90d9795cd074ff9e60029";
Which means, that web3j or solidity compiler does not correctly do its job. Personal issue, but it was not obvious.
Don't know if it can help out, but I had the same issue and in my wrapped compiled solidity script, it was :
private static final String BINARY = "[{\"constant\":true,\"inputs\":[],\"name\":\"chars\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}, ( ... )se,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]";
instead of :
private static final String BINARY = "608060405234801561001057600080fd5b5060008054600160a060020a0319163317815560015561027f806100356000 (...) ffffffffffffffffffff163314156102515760005473ffffffffffffffffffffffffffffffffffffffff16ff5b5600a165627a7a72305820545e60010ee0d4b8f1315f9743499c370f058e1ab280aab90d9795cd074ff9e60029";
Which means, that web3j or solidity compiler does not correctly do its job. Personal issue, but it was not obvious.
I had the same problem with wrong binary string.
Contract can deploy successfully in remix,but it can not be deploy with web3j.Finally,I found the binary string was wrong ,if I get .bin file by solcjs . I don't not why if I choose to get .bin from remix ,that is right.
I got the same error. In my case it was about issues of Gas Price and Gas Limit.
I obtain de same problem. I am not sure if I have the binary contract code fine: { "linkReferences": {}, "object": "608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008090505b60088110156100f55760016002826008811061006f57fe5b6002020160010160146101000a81548160ff02191690831515021790555060006002828161009957fe5b0614156100c65767016345785d8a0000600282600881106100b657fe5b60020201600001819055506100e8565b6702c68af0bb140000600282600881106100dc57fe5b60020201600001819055505b8080600101915050610057565b50610719806101056000396000f3fe6080604052600436106100705760003560e01c80637c60007e1161004e5780637c60007e14610142578063a64922281461018a578063caf59ab814610205578063f16112ae1461024f57610070565b8063195225541461007557806341654d7f146100c457806357830655146100ef575b600080fd5b34801561008157600080fd5b506100ae6004803603602081101561009857600080fd5b8101908080359060200190929190505050610294565b6040518082815260200191505060405180910390f35b3480156100d057600080fd5b506100d96102b2565b6040518082815260200191505060405180910390f35b3480156100fb57600080fd5b506101286004803603602081101561011257600080fd5b81019080803590602001909291905050506102bb565b604051808215151515815260200191505060405180910390f35b34801561014e57600080fd5b506101886004803603604081101561016557600080fd5b81019080803560ff169060200190929190803590602001909291905050506102e6565b005b34801561019657600080fd5b506101c3600480360360208110156101ad57600080fd5b810190808035906020019092919050505061035f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061024d6004803603604081101561022857600080fd5b81019080803560ff16906020019092919080351515906020019092919050505061039d565b005b61027e6004803603602081101561026557600080fd5b81019080803560ff169060200190929190505050610487565b6040518082815260200191505060405180910390f35b6000600282600881106102a357fe5b60020201600001549050919050565b60006008905090565b6000600282600881106102ca57fe5b6002020160010160149054906101000a900460ff169050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461033f57600080fd5b8060028360ff166008811061035057fe5b60020201600001819055505050565b60006002826008811061036e57fe5b6002020160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103f657600080fd5b8060028360ff166008811061040757fe5b6002020160010160146101000a81548160ff021916908315150217905550801561048357600060028360ff166008811061043d57fe5b6002020160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5050565b600033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600060028360ff16600881106104dc57fe5b600202016000015434816104ec57fe5b061480156104fa5750600034115b801561052e57506001151560028360ff166008811061051557fe5b6002020160010160149054906101000a900460ff161515145b1561067157600060028360ff166008811061054557fe5b6002020160000154348161055557fe5b049050600060028460ff166008811061056a57fe5b6002020160010160146101000a81548160ff021916908315150217905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660028460ff16600881106105bb57fe5b6002020160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610667573d6000803e3d6000fd5b50809150506106df565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156106d9573d6000803e3d6000fd5b50600090505b91905056fea265627a7a723158206ea53c46c59eb0fd027ce77f622d2706023d83bd1395e87a2f0ba230f3927a4864736f6c63430005110032", "opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP CALLER PUSH1 0x0 DUP1 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP PUSH1 0x0 DUP1 SWAP1 POP JUMPDEST PUSH1 0x8 DUP2 LT ISZERO PUSH2 0xF5 JUMPI PUSH1 0x1 PUSH1 0x2 DUP3 PUSH1 0x8 DUP2 LT PUSH2 0x6F JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x1 ADD PUSH1 0x14 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH1 0xFF MUL NOT AND SWAP1 DUP4 ISZERO ISZERO MUL OR SWAP1 SSTORE POP PUSH1 0x0 PUSH1 0x2 DUP3 DUP2 PUSH2 0x99 JUMPI INVALID JUMPDEST MOD EQ ISZERO PUSH2 0xC6 JUMPI PUSH8 0x16345785D8A0000 PUSH1 0x2 DUP3 PUSH1 0x8 DUP2 LT PUSH2 0xB6 JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x0 ADD DUP2 SWAP1 SSTORE POP PUSH2 0xE8 JUMP JUMPDEST PUSH8 0x2C68AF0BB140000 PUSH1 0x2 DUP3 PUSH1 0x8 DUP2 LT PUSH2 0xDC JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x0 ADD DUP2 SWAP1 SSTORE POP JUMPDEST DUP1 DUP1 PUSH1 0x1 ADD SWAP2 POP POP PUSH2 0x57 JUMP JUMPDEST POP PUSH2 0x719 DUP1 PUSH2 0x105 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN INVALID PUSH1 0x80 PUSH1 0x40 MSTORE PUSH1 0x4 CALLDATASIZE LT PUSH2 0x70 JUMPI PUSH1 0x0 CALLDATALOAD PUSH1 0xE0 SHR DUP1 PUSH4 0x7C60007E GT PUSH2 0x4E JUMPI DUP1 PUSH4 0x7C60007E EQ PUSH2 0x142 JUMPI DUP1 PUSH4 0xA6492228 EQ PUSH2 0x18A JUMPI DUP1 PUSH4 0xCAF59AB8 EQ PUSH2 0x205 JUMPI DUP1 PUSH4 0xF16112AE EQ PUSH2 0x24F JUMPI PUSH2 0x70 JUMP JUMPDEST DUP1 PUSH4 0x19522554 EQ PUSH2 0x75 JUMPI DUP1 PUSH4 0x41654D7F EQ PUSH2 0xC4 JUMPI DUP1 PUSH4 0x57830655 EQ PUSH2 0xEF JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x81 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xAE PUSH1 0x4 DUP1 CALLDATASIZE SUB PUSH1 0x20 DUP2 LT ISZERO PUSH2 0x98 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x294 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 DUP3 DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xD0 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0xD9 PUSH2 0x2B2 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 DUP3 DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0xFB JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x128 PUSH1 0x4 DUP1 CALLDATASIZE SUB PUSH1 0x20 DUP2 LT ISZERO PUSH2 0x112 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x2BB JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 DUP3 ISZERO ISZERO ISZERO ISZERO DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x14E JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x188 PUSH1 0x4 DUP1 CALLDATASIZE SUB PUSH1 0x40 DUP2 LT ISZERO PUSH2 0x165 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD PUSH1 0xFF AND SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 DUP1 CALLDATALOAD SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x2E6 JUMP JUMPDEST STOP JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x196 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x1C3 PUSH1 0x4 DUP1 CALLDATASIZE SUB PUSH1 0x20 DUP2 LT ISZERO PUSH2 0x1AD JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x35F JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 DUP3 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST CALLVALUE DUP1 ISZERO PUSH2 0x211 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x24D PUSH1 0x4 DUP1 CALLDATASIZE SUB PUSH1 0x40 DUP2 LT ISZERO PUSH2 0x228 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD PUSH1 0xFF AND SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 DUP1 CALLDATALOAD ISZERO ISZERO SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x39D JUMP JUMPDEST STOP JUMPDEST PUSH2 0x27E PUSH1 0x4 DUP1 CALLDATASIZE SUB PUSH1 0x20 DUP2 LT ISZERO PUSH2 0x265 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP2 ADD SWAP1 DUP1 DUP1 CALLDATALOAD PUSH1 0xFF AND SWAP1 PUSH1 0x20 ADD SWAP1 SWAP3 SWAP2 SWAP1 POP POP POP PUSH2 0x487 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 DUP3 DUP2 MSTORE PUSH1 0x20 ADD SWAP2 POP POP PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH1 0x0 PUSH1 0x2 DUP3 PUSH1 0x8 DUP2 LT PUSH2 0x2A3 JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x0 ADD SLOAD SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x8 SWAP1 POP SWAP1 JUMP JUMPDEST PUSH1 0x0 PUSH1 0x2 DUP3 PUSH1 0x8 DUP2 LT PUSH2 0x2CA JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x1 ADD PUSH1 0x14 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH1 0xFF AND SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP1 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND CALLER PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND EQ PUSH2 0x33F JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP1 PUSH1 0x2 DUP4 PUSH1 0xFF AND PUSH1 0x8 DUP2 LT PUSH2 0x350 JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x0 ADD DUP2 SWAP1 SSTORE POP POP POP JUMP JUMPDEST PUSH1 0x0 PUSH1 0x2 DUP3 PUSH1 0x8 DUP2 LT PUSH2 0x36E JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x1 ADD PUSH1 0x0 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND SWAP1 POP SWAP2 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP1 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND CALLER PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND EQ PUSH2 0x3F6 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST DUP1 PUSH1 0x2 DUP4 PUSH1 0xFF AND PUSH1 0x8 DUP2 LT PUSH2 0x407 JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x1 ADD PUSH1 0x14 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH1 0xFF MUL NOT AND SWAP1 DUP4 ISZERO ISZERO MUL OR SWAP1 SSTORE POP DUP1 ISZERO PUSH2 0x483 JUMPI PUSH1 0x0 PUSH1 0x2 DUP4 PUSH1 0xFF AND PUSH1 0x8 DUP2 LT PUSH2 0x43D JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x1 ADD PUSH1 0x0 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP JUMPDEST POP POP JUMP JUMPDEST PUSH1 0x0 CALLER PUSH1 0x1 PUSH1 0x0 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP PUSH1 0x0 PUSH1 0x2 DUP4 PUSH1 0xFF AND PUSH1 0x8 DUP2 LT PUSH2 0x4DC JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x0 ADD SLOAD CALLVALUE DUP2 PUSH2 0x4EC JUMPI INVALID JUMPDEST MOD EQ DUP1 ISZERO PUSH2 0x4FA JUMPI POP PUSH1 0x0 CALLVALUE GT JUMPDEST DUP1 ISZERO PUSH2 0x52E JUMPI POP PUSH1 0x1 ISZERO ISZERO PUSH1 0x2 DUP4 PUSH1 0xFF AND PUSH1 0x8 DUP2 LT PUSH2 0x515 JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x1 ADD PUSH1 0x14 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH1 0xFF AND ISZERO ISZERO EQ JUMPDEST ISZERO PUSH2 0x671 JUMPI PUSH1 0x0 PUSH1 0x2 DUP4 PUSH1 0xFF AND PUSH1 0x8 DUP2 LT PUSH2 0x545 JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x0 ADD SLOAD CALLVALUE DUP2 PUSH2 0x555 JUMPI INVALID JUMPDEST DIV SWAP1 POP PUSH1 0x0 PUSH1 0x2 DUP5 PUSH1 0xFF AND PUSH1 0x8 DUP2 LT PUSH2 0x56A JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x1 ADD PUSH1 0x14 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH1 0xFF MUL NOT AND SWAP1 DUP4 ISZERO ISZERO MUL OR SWAP1 SSTORE POP PUSH1 0x1 PUSH1 0x0 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH1 0x2 DUP5 PUSH1 0xFF AND PUSH1 0x8 DUP2 LT PUSH2 0x5BB JUMPI INVALID JUMPDEST PUSH1 0x2 MUL ADD PUSH1 0x1 ADD PUSH1 0x0 PUSH2 0x100 EXP DUP2 SLOAD DUP2 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF MUL NOT AND SWAP1 DUP4 PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND MUL OR SWAP1 SSTORE POP PUSH1 0x0 DUP1 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH2 0x8FC CALLVALUE SWAP1 DUP2 ISZERO MUL SWAP1 PUSH1 0x40 MLOAD PUSH1 0x0 PUSH1 0x40 MLOAD DUP1 DUP4 SUB DUP2 DUP6 DUP9 DUP9 CALL SWAP4 POP POP POP POP ISZERO DUP1 ISZERO PUSH2 0x667 JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP DUP1 SWAP2 POP POP PUSH2 0x6DF JUMP JUMPDEST PUSH1 0x1 PUSH1 0x0 SWAP1 SLOAD SWAP1 PUSH2 0x100 EXP SWAP1 DIV PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF AND PUSH2 0x8FC CALLVALUE SWAP1 DUP2 ISZERO MUL SWAP1 PUSH1 0x40 MLOAD PUSH1 0x0 PUSH1 0x40 MLOAD DUP1 DUP4 SUB DUP2 DUP6 DUP9 DUP9 CALL SWAP4 POP POP POP POP ISZERO DUP1 ISZERO PUSH2 0x6D9 JUMPI RETURNDATASIZE PUSH1 0x0 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x0 REVERT JUMPDEST POP PUSH1 0x0 SWAP1 POP JUMPDEST SWAP2 SWAP1 POP JUMP INVALID LOG2 PUSH6 0x627A7A723158 KECCAK256 PUSH15 0xA53C46C59EB0FD027CE77F622D2706 MUL RETURNDATASIZE DUP4 0xBD SGT SWAP6 0xE8 PUSH27 0x2F0BA230F3927A4864736F6C634300051100320000000000000000 ", "sourceMap": "61:4597:0:-;;;1068:601;8:9:-1;5:2;;;30:1;27;20:12;5:2;1068:601:0;1194:10;1176:15;;:28;;;;;;;;;;;;;;;;;;1417:6;1426:1;1417:10;;1412:251;1433:1;1429;:5;1412:251;;;1483:4;1455:6;1462:1;1455:9;;;;;;;;;;:25;;;:32;;;;;;;;;;;;;;;;;;1514:1;1509;1505;:5;;;;;;:10;1501:152;;;1558:9;1535:6;1542:1;1535:9;;;;;;;;;;:20;;:32;;;;1501:152;;;1629:9;1606:6;1613:1;1606:9;;;;;;;;;;:20;;:32;;;;1501:152;1436:3;;;;;;;1412:251;;;;61:4597;;;;;;" }
This obtain binary code from remix ... but I obtain the following error in Android console: java.util.concurrent.ExecutionException: org.web3j.tx.exceptions.ContractCallException: Empty value (0x) returned from contract at java8.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:386) at java8.util.concurrent.CompletableFuture.get(CompletableFuture.java:2064) at com.example.testuserapp.viewmodels.EthBnbViewModel$getContactData$1.invokeSuspend(EthBnbViewModel.kt:32) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) Caused by: org.web3j.tx.exceptions.ContractCallException: Empty value (0x) returned from contract at org.web3j.tx.Contract.executeCallSingleValueReturn(Contract.java:252) at org.web3j.tx.Contract.lambda$executeRemoteCallSingleValueReturn$1$Contract(Contract.java:319) at org.web3j.tx.Contract$$ExternalSyntheticLambda14.call(Unknown Source:6) at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:31) at org.web3j.protocol.core.RemoteCall$$ExternalSyntheticLambda0.call(Unknown Source:2) at org.web3j.utils.Async.lambda$run$1(Async.java:28) at org.web3j.utils.Async$$ExternalSyntheticLambda1.run(Unknown Source:4) at java8.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1801) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923)
Hi,When i use java build contract on Windows 10, web3j 3.2.0. It's response me Empty value (0x) returned from contract.But i got the contract address and credentials.
The step is :
1. the pom.xml is :
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>3.2.0</version>
</dependency>
the contract is :
` pragma solidity ^0.4.19; contract HelloWorld{
} `
2. the java contract is :
import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; import org.web3j.abi.FunctionEncoder; import org.web3j.abi.TypeReference; import org.web3j.abi.datatypes.Function; import org.web3j.abi.datatypes.Type; import org.web3j.abi.datatypes.Utf8String; import org.web3j.crypto.Credentials; import org.web3j.protocol.Web3j; import org.web3j.protocol.core.RemoteCall; import org.web3j.protocol.core.methods.response.TransactionReceipt; import org.web3j.tx.Contract; import org.web3j.tx.TransactionManager;
/**
Generated with web3j version 3.2.0. */ public class HelloWorld extends Contract { private static final String BINARY = "6060604052341561000f57600080fd5b6040516104d03803806104d083398101604052808051820191905050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060019080519060200190610081929190610088565b505061012d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100c957805160ff19168380011785556100f7565b828001600101855582156100f7579182015b828111156100f65782518255916020019190600101906100db565b5b5090506101049190610108565b5090565b61012a91905b8082111561012657600081600090555060010161010e565b5090565b90565b6103948061013c6000396000f300606060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806341c0e1b51461005c578063a413686214610071578063cfae3217146100ce575b600080fd5b341561006757600080fd5b61006f61015c565b005b341561007c57600080fd5b6100cc600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506101ed565b005b34156100d957600080fd5b6100e1610207565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610121578082015181840152602081019050610106565b50505050905090810190601f16801561014e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101eb576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b565b80600190805190602001906102039291906102af565b5050565b61020f61032f565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102a55780601f1061027a576101008083540402835291602001916102a5565b820191906000526020600020905b81548152906001019060200180831161028857829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102f057805160ff191683800117855561031e565b8280016001018555821561031e579182015b8281111561031d578251825591602001919060010190610302565b5b50905061032b9190610343565b5090565b602060405190810160405280600081525090565b61036591905b80821115610361576000816000905550600101610349565b5090565b905600a165627a7a7230582054721911b522185a0d4c0bcf50b95120f763f5c87f5c55c82b7da738247863ac0029\r\n"; protected HelloWorld(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } protected HelloWorld(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } public RemoteCall kill() {
Function function = new Function(
"kill",
Arrays.asList(),
Collections.>emptyList());
return executeRemoteCallTransaction(function);
}
public RemoteCall setGreeting(String _newgreeting) {
Function function = new Function(
"setGreeting",
Arrays.asList(new Utf8String(_newgreeting)),
Collections.>emptyList());
return executeRemoteCallTransaction(function);
}
public RemoteCall greet() {
Function function = new Function("greet",
Arrays.asList(),
Arrays.>asList(new TypeReference() {}));
return executeRemoteCallSingleValueReturn(function, String.class);
}
public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, String _greeting) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.asList(new Utf8String(_greeting)));
return deployRemoteCall(HelloWorld.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor);
}
public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, String _greeting) {
String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.asList(new Utf8String(_greeting)));
return deployRemoteCall(HelloWorld.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor);
}
public static HelloWorld load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
return new HelloWorld(contractAddress, web3j, credentials, gasPrice, gasLimit);
}
public static HelloWorld load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
return new HelloWorld(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
}
}
3. the building contract code is :
`
4. the response is :
contract address is :0x78d12ebe81703c347d3a03b66601c7180fcc5c2c set:0xc9cd2ef57752eacde42d78fc9a30201c09220a2a4dc1debe5a2f1f0987adfea3 contract is valid::false Exception in thread "main" org.web3j.tx.exceptions.ContractCallException: Empty value (0x) returned from contract at org.web3j.tx.Contract.executeCallSingleValueReturn(Contract.java:178) at org.web3j.tx.Contract.lambda$executeRemoteCallSingleValueReturn$1(Contract.java:232) at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:30) at Test.BuildContract(Test.java:136) at Test.main(Test.java:47)
And the line 136 is :String result=contract.greet().send();
Thank you!!