0

There are 2 smart contract

contract A {
function abc(string _a) public returns (address) {
    return new B(_a);
 }
}
contract B {
  function xyz(string _a) {
  A a = A(contact address); // interface
  a.abc(_a); 
  }
}

How can i get the value of function abc() when i am making a call from function xyz() of contract B which DOES NOT have a return. Especially in Remix and also through web3.js please guide.

1 Answers1

0

This should work

contract A {
function abc(string _a) public returns (address) {
    return new B(_a);
 }
}
contract B {
  function xyz(string _a) {
  A a = A(contact address);
  address addr = a.abc(_a);
  //do something with addr; 
  }
}
ruby_newbie
  • 304
  • 1
  • 7
  • how do i get the value of address when there is no return ? – Taha Dhailey Feb 05 '19 at 20:06
  • If you want the value you have to return it from xyz(), or save it to state to access it with another call. Since that variable is only in memory, it disappears as soon as the call to xyz() completes. – ruby_newbie Feb 05 '19 at 20:37