- I created a contract named
Pepito
by callingnew
inweb3
:
import Pepito from "./contracts_abi/Pepito.json";
const instance = new web3.eth.Contract(
Pepito.abi,
address,
);
- Inside
Pepito.sol
there is a function that callsnew
in solidity
import "./PepitoDisguise.sol";
function createPepitoDisguise() public returns(PepitoDisguise) {
PepitoDisguise pepitoDisguise = new PepitoDisguise(owner);
return pepitoDisguise;
}
- I call
createPepitoDisguise
fromweb3
by calling the function inside Pepito
const pepitoDisguise = await instance.methods.createPepitoDisguise();
My question is: how come that in case 1 a contract is returned and in case 2 a transaction object (https://web3js.readthedocs.io/en/v1.2.11/web3-eth-contract.html#id24) is returned?
The answer is important for me because when a contract Pepito is returned, I can call a function of Pepito but when a transaction object is returned after new PepitoDisguise
, I cannot. I need to call a function also in PepitoDisguise
. How can I get this new
Contract?