Lets say i have a contract which includes a function that deploys new ERC721 contract:
function createCollection(
uint256 _price, uint256 _maxSupply, string memory _name, string memory _symbol,
address _requsetFrom, string memory _uri, bytes32 salt
) external payable returns(address) {
if (msg.value < s_createFee) {
revert CollectionCreator__InsufficientAmount();
}
CollectionV2 newNft = new CollectionV2(_name,_symbol,_price,_maxSupply,_requsetFrom, _uri);
address _contractAddress = address(newNft);
ownerToCollection[_requsetFrom].push(_contractAddress);
emit NewCollection(_requsetFrom, _contractAddress);
return(_contractAddress);
}
And i returned the address of new contract, but when i want to get address of new contract in the backend it returns me the transaction:
const Collection = await ERC721Creator.createCollection(10,100,'test','tst',deployer.address,'someuri')
await Collection.wait(1)
console.log(Collection);
It returns me a ton of information about this transaction, what i must to do? thanks
According to Rohan answer i got address this way:
const Collection = await ERC721Creator.createCollection(10,100,'test','tst',deployer.address,'someuri')
const tx = await Collection.wait(1)
const newContractAddress = tx.events[0].args[1]