Comparison of 2 child-contract-values in factory-contract

by Siewi   Last Updated October 17, 2019 15:28 PM - source

in my solidity code I create a tracking-contract and auction-contracts out of a factory-contract. The last function 'a4_Payment' of the auction-contract should be triggered out of the master-contract in the 'ProofOfDelivery'-function with a requirement that the destination defined in the auction is the same as the recent address in the tracking-contract. This requirement doesn't work for me and I am at a loss of what the problem is. The thing is that it worked quite well until I added another entity to the 'createAuction'-function. In the current code I add the recent address of the tracking-contract as the 'departure' for the auction. Without this addition my requirement for the 'ProofOfDelivery' worked fine. Do I run into some sort of loop right now? Compiling the whole thing works but then I can't deploy my master-contract.

Current code:

pragma solidity ^0.5.11; 
pragma experimental ABIEncoderV2;

//Master contrauctor-tracking + RecentAddress ohne ProofOfDelivery

contract PI_Container {

    Auction auction;
    Tracking tracking;

    address NewAuction;
    address Pi_C_Owner;
    address public NewTracking;
    address payable public NewAuctionPayable;

    constructor() public {
        NewTracking = address (new Tracking(msg.sender));
        tracking = Tracking(NewTracking);
        Pi_C_Owner = msg.sender;

    function checkBalance() public view returns(uint) { 
        require(msg.sender == Pi_C_Owner,"Insufficient permission");

    function increaseBalance() public payable {
        require(msg.sender == Pi_C_Owner,"Insufficient permission");

    function createAuction(address _Destination, uint _WTP, uint _BiddingTime) public returns(address) {
        require(_WTP > 0,"Willingness to pay has to exceed 0.");
        require(_BiddingTime > 0,"Bidding time has to exceed 0.");
        NewAuction = address (new Auction(tracking.RecentAddress(), _Destination, _WTP, _BiddingTime, address(this)));
        NewAuctionPayable = address(uint160(NewAuction));
        auction = Auction(NewAuctionPayable);

    function ProofOfDelivery() public {
        //require(auction.Destination() == tracking.RecentAddress(),"Destination not yet reached.");

    function() external payable {

contract Tracking {

    uint RecordId;
    uint public RecordCount;
    address public RecentAddress;

    struct Record{
        uint id;
        address adr;            
        string pifunction;
        string coordinates;
        uint time;

    mapping(uint => Record) records;

    constructor(address _Source) public {
        RecentAddress = _Source;

    function a_addRecord(string memory PI_Function, string memory Coordinates) public {
        records[RecordId] = Record(RecordId, msg.sender, PI_Function, Coordinates, now);
        RecordCount = RecordId;
        RecentAddress = msg.sender;

    function b_getRecord(uint RecordID) public view returns(Record memory) {
        return records[RecordID];

    function c_getAddresses() public view returns(address[] memory) {
        address[] memory adr = new address[](RecordId);
        for(uint i = 0; i < RecordId; i++) {
            Record storage record = records[i];
            adr[i] = record.adr;

    function d_getPI_Functions() public view returns(string[] memory) {
        string[] memory pifunction = new string[](RecordId);
        for(uint i = 0; i < RecordId; i++) {
            Record storage record = records[i];
            pifunction[i] = record.pifunction;

    function e_getCoordinates() public view returns(string[] memory) {
        string[] memory coordinates = new string[](RecordId);
        for(uint i = 0; i < RecordId; i++) {
            Record storage record = records[i];
            coordinates[i] = record.coordinates;

contract Auction {

    bool Ended;
    uint WTP;
    uint public LowestBid;
    uint public SafetyDeposit;
    uint public AuctionEndTime;
    address public Departure;
    address public Destination;
    address payable MasterPayable;
    address payable LowestBidder;
    address payable Payee;

    struct Participant {
        bool biddingright;
        uint amount;

    mapping(address => Participant) participants;
    address payable[] depositor;

    constructor(address _Departure, address _Destination, uint _WTP, uint _BiddingTime, address payable _Master) public {
        Departure = _Departure;
        Destination = _Destination;
        WTP = _WTP;
        SafetyDeposit = _WTP/2;
        LowestBid = _WTP;
        AuctionEndTime = now + _BiddingTime;
        MasterPayable = _Master;
        Ended = false;

    function a1_getRights() public payable { 
        require(now <= AuctionEndTime,"Auction already ended.");
        require(msg.value >= SafetyDeposit,"Value has to atleast amount to 'safety deposit'.");
        require(participants[msg.sender].biddingright == false,"Safety deposit already payed.");
        participants[msg.sender].biddingright = true;
        participants[msg.sender].amount = msg.value;

    function a2_placeBid(uint Bid) public {                                         
        require(now <= AuctionEndTime,"Auction already ended.");
        require(Bid < LowestBid,"There already is a lower bid.");
        require(participants[msg.sender].biddingright == true,"Please note safety deposit.");
        LowestBidder = msg.sender;
        LowestBid = Bid;

    function a3_AuctionEnd() public {
        require(now >= AuctionEndTime,"Auction not yet ended.");
        require(Ended == false,"Auction end has already been called.");
        Ended = true;
        for(uint i=0; i<depositor.length; i++) {
            Payee = depositor[i];
            if(Payee != LowestBidder) {

    function a4_Payment() public {
        require(Ended == true,"Destination not yet reached.");

    function() external payable {

I know that this is a lot to take in but I feel stuck right now and would really need some help.

Thanks in advance.

Related Questions

I need help with a crowdfunding contract

Updated July 27, 2017 13:28 PM

How to interact with Smart Contracts (for test)

Updated August 10, 2017 10:28 AM

Testing for Reentrancy attacks in remix

Updated October 21, 2017 13:28 PM