CRYPTO NEWS

I want to add the struct "Request" with a mapping field, to an array? below is my code

//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.9;   contract Campaign {    address public manager;    uint minimumContribution;    mapping(address => bool) public approvers;    Request[] public requests;      struct Request {       string description;       uint value;       address recipient;       bool complete;       uint approvalCount;       mapping (address => bool) approvals;     }      uint requestsIndex;     //state variable for request struct     mapping (uint => Request) mapRequests;      modifier restricted(){         require(msg.sender == manager);         _;     }     constructor(uint minimum){        manager = msg.sender;        minimumContribution = minimum;     }      function createRequest(string memory description, uint value, address recipient) public restricted {       //use this approach when you have a map field in a struct.        requestsIndex++;          Request storage request = mapRequests[requestsIndex];        request.description = description;        request.value = value;        request.recipient = recipient;        request.complete = false;        request.approvalCount = 0;         requests.push();            } }  

Ethers.js not detecting Contract emitting event

I have contract factory that creates a new contract and it emits an event called Created when a new FundMe contract is created: contract FundFactory { // Events event Created( address indexed owner, address indexed assetAddress, address indexed fundAddress ); // Variables address public i_owner; FundMe[] public s_funds; constructor() { i_owner = msg.sender; } function::Listen

I have contract factory that creates a new contract and it emits an event called Created when a new FundMe contract is created:

contract FundFactory {     // Events     event Created(         address indexed owner,         address indexed assetAddress,         address indexed fundAddress     );      // Variables     address public i_owner;     FundMe[] public s_funds;      constructor() {         i_owner = msg.sender;     }  function createFundMe(         uint256 lockTime,         address assetAddress,         address assetAddress2,     ) public returns (address) {         FundMe fundMe = new FundMe(lockTime, assetAddress, assetAddress2);         s_funds.push(fundMe);         emit Created(msg.sender, assetAddress, address(fundMe));     } 

I’m trying to access the newly created FundMe contract, so I’m trying to get the address from the event that gets emitted. I have tried to listen for the event by using ether’s provider.on function, but I haven’t been able to get that to fire. Here is my code for that:

await deploy("FundFactory", {         from: deployer,         args: [],         log: true,         waitConfirmations: networkConfig[chainId].blockConfirmations || 1,     })      const fundFactory = await ethers.getContract("FundFactory")      const createFundTx = await fundFactory.createFundMe(         locktime,         assetAddress,         assetAddress2     )      await createFundTx.wait(1)      const filter = {         address: fundFactory.address,         topics: [utils.id("Created(address,address,address)")],     }     const provider = ethers.getDefaultProvider()     provider.on(filter, (owner, assetAddress, fundAddress) => {         console.log("hello")         console.log(owner, assetAddress, fundAddress)     }) 

The deploy goes through without erroring, but not only am I not able to print out the actual contents of the event,the console.log(hello) doesn’t even get fired… I’m really not sure what I’m doing wrong here. Could it be because I’m using the hardhat local environment yarn hardhat deploy?

I want to add the struct "Request" with a mapping field, to an array? below is my code

Shopping cart
There are no products in the cart!
Continue shopping
0