I'm working with 2 contracts, one that manages users bets for a specific football match and another (factory style) that generates these individual contracts to be managed separately.
The Generator contract is this:
pragma solidity ^0.8.0;
contract Generator {
address immutable public owner;
string public matchGenerated;
Management[] public bettingHistory;
constructor(string memory _league, string memory _match) {
owner = msg.sender;
matchGenerated = string(abi.encodePacked(_league, "_", _match));
Management newBetContract = new Management(address(this));
bettingHistory.push(newBetContract);
}
}
The Management contract receives data from the Generator to define the manager and the match values, as follows (short version):
contract Management {
address payable immutable public manager;
string public matchDispute;
Generator generator;
constructor(address _contract) {
generator = Generator(_contract);
manager = payable(generator.owner());
matchDispute = generator.matchGenerated();
}
Once I try to deploy the Generator contract in Remix it results in a reverting error. If I remove the instance of the generator in the Management contract and repeat the constructor arguments in both contracts it works, but I want to avoid the redundancy and get the values already stored in the Generator variables automatically.
creation of BetGenerator errored: VM error: revert. revert The transaction has been reverted to the initial state.
– TG555