0

Simplified version of my contracts works

MyContract

  • await contract.methods.info().call() Works indicating that there is no error in the MyContract itself.

Launchpad

  • There is no issues when launching MyContract using launchpad contract since I get address to a newly published contract.

The problem is that when I call the contract created with Launchpad contract in JavaScript I get the following error

Uncaught (in promise) Error: Couldn't decode uint256 from ABI: 0x

contract MyContract {
  function info() external view returns(uint min, uint max) {
    return(1, 2);
  }
}

contract Launchpad {

 function launch() public returns(address) {
   MyContract myContractAddress = new MyContract();
   return myContractAddress;
 }

}
  • 1
    "since I get address to a newly published contract" <-- How? Transactions don't have return values, so when you call launch, there's no way for you to get back the address of the new contract. The typical solution is to log an event and read that from JavaScript. – smarx May 9 '18 at 12:50
  • Or you can just add pure to the declaration of function launch. – goodvibration May 9 '18 at 12:51
  • return myContractAddress gives me the address to the new contract – Arash Kiani May 9 '18 at 12:52
  • 1
    Right. So now foo holds a hash of the transaction receipt, which you need to decode. And by the way, since you do not emit an event which contains myContractAddress in the launch function, this value is not going to be available to you even after you decode the hash. – goodvibration May 9 '18 at 12:56
  • 3
    Possible duplicate of What is the difference between a transaction and a call? – Ismael May 10 '18 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.