Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Rollback to Revision 2
Source Link
eth
  • 86.5k
  • 53
  • 287
  • 411

Can GanacheI am trying to push data to an address array within a struct array. There are no errors, however, when I check the storage support mappingsof the array in my contract in Ganache, it remains empty. Is there something wrong with my code? Or is it not meant to display in Ganache? And if the data doesn't display in Ganache, does that mean it isn't being stored anywhere?

My code is provided below. I am trying to push data to the address array challengers in struct array challenges through function acceptChallenge.

pragma solidity >=0.5.0 <0.6.0;

contract GameChanger {

    uint ChallengeCount = 0;

    struct Challenge {
        string name;
        address host;
        string description;
        uint starttime;
        uint timelimit;
        uint reward;
        uint challengercount;
        address[] challengers;
    }

    Challenge[] public challenges;

    function createChallenge(string memory name, string memory description, 
        uint timelimit, uint reward) public {

        ChallengeCount++;
        address host = msg.sender;
        uint starttime = now;
        uint challengercount = 0;
        challenges.push(Challenge(name, host, description, starttime,                         
        timelimit, reward, challengercount, new address[](0)));
    }

    function acceptChallenge(uint ChallengeCount) public {

        if (now <= ((challenges[ChallengeCount].starttime)  + 24)) {
            challenges[ChallengeCount].challengers.push(msg.sender);
            challenges[ChallengeCount].challengercount++;
            uint id = challenges[ChallengeCount].challengercount;
            registration[id] = msg.sender;
        }
    }
}

Can Ganache storage support mappings?

I am trying to push data to an address array within a struct array. There are no errors, however, when I check the storage of the array in my contract in Ganache, it remains empty. Is there something wrong with my code? Or is it not meant to display in Ganache? And if the data doesn't display in Ganache, does that mean it isn't being stored anywhere?

My code is provided below. I am trying to push data to the address array challengers in struct array challenges through function acceptChallenge.

pragma solidity >=0.5.0 <0.6.0;

contract GameChanger {

    uint ChallengeCount = 0;

    struct Challenge {
        string name;
        address host;
        string description;
        uint starttime;
        uint timelimit;
        uint reward;
        uint challengercount;
        address[] challengers;
    }

    Challenge[] public challenges;

    function createChallenge(string memory name, string memory description, 
        uint timelimit, uint reward) public {

        ChallengeCount++;
        address host = msg.sender;
        uint starttime = now;
        uint challengercount = 0;
        challenges.push(Challenge(name, host, description, starttime,                         
        timelimit, reward, challengercount, new address[](0)));
    }

    function acceptChallenge(uint ChallengeCount) public {

        if (now <= ((challenges[ChallengeCount].starttime)  + 24)) {
            challenges[ChallengeCount].challengers.push(msg.sender);
            challenges[ChallengeCount].challengercount++;
            uint id = challenges[ChallengeCount].challengercount;
            registration[id] = msg.sender;
        }
    }
}
deleted 1810 characters in body
Source Link

I am trying to push data to an address array within a struct array. There are no errors, however, when I check the storage of the array in my contract in Ganache, it remains empty. Is there something wrong with my code? Or is it not meant to display in Ganache? And if the data doesn't display inCan Ganache, does that mean it isn't being stored anywhere storage support mappings?

My code is provided below. I am trying to push data to the address array challengers in struct array challenges through function acceptChallenge.

pragma solidity >=0.5.0 <0.6.0;

contract GameChanger {

    uint ChallengeCount = 0;

    struct Challenge {
        string name;
        address host;
        string description;
        uint starttime;
        uint timelimit;
        uint reward;
        uint challengercount;
        address[] challengers;
    }

    Challenge[] public challenges;

    function createChallenge(string memory name, string memory description, 
        uint timelimit, uint reward) public {

        ChallengeCount++;
        address host = msg.sender;
        uint starttime = now;
        uint challengercount = 0;
        challenges.push(Challenge(name, host, description, starttime,                         
        timelimit, reward, challengercount, new address[](0)));
    }

    function acceptChallenge(uint ChallengeCount) public {

        if (now <= ((challenges[ChallengeCount].starttime)  + 24)) {
            challenges[ChallengeCount].challengers.push(msg.sender);
            challenges[ChallengeCount].challengercount++;
            uint id = challenges[ChallengeCount].challengercount;
            registration[id] = msg.sender;
        }
    }
}

I am trying to push data to an address array within a struct array. There are no errors, however, when I check the storage of the array in my contract in Ganache, it remains empty. Is there something wrong with my code? Or is it not meant to display in Ganache? And if the data doesn't display in Ganache, does that mean it isn't being stored anywhere?

My code is provided below. I am trying to push data to the address array challengers in struct array challenges through function acceptChallenge.

pragma solidity >=0.5.0 <0.6.0;

contract GameChanger {

    uint ChallengeCount = 0;

    struct Challenge {
        string name;
        address host;
        string description;
        uint starttime;
        uint timelimit;
        uint reward;
        uint challengercount;
        address[] challengers;
    }

    Challenge[] public challenges;

    function createChallenge(string memory name, string memory description, 
        uint timelimit, uint reward) public {

        ChallengeCount++;
        address host = msg.sender;
        uint starttime = now;
        uint challengercount = 0;
        challenges.push(Challenge(name, host, description, starttime,                         
        timelimit, reward, challengercount, new address[](0)));
    }

    function acceptChallenge(uint ChallengeCount) public {

        if (now <= ((challenges[ChallengeCount].starttime)  + 24)) {
            challenges[ChallengeCount].challengers.push(msg.sender);
            challenges[ChallengeCount].challengercount++;
            uint id = challenges[ChallengeCount].challengercount;
            registration[id] = msg.sender;
        }
    }
}

Can Ganache storage support mappings?

I am trying to push data to an address array within a struct array. There are no errors, however, when I check the storage of the array in my contract in Ganache, it remains empty. Is there something wrong with my code? Or is it not meant to display in Ganache? And if the data doesn't display in Ganache, does that mean it isn't being stored anywhere?

My code is provided below. I am trying to push data to the address array challengers in struct array challenges through function acceptChallenge.

pragma solidity >=0.5.0 <0.6.0;

pragma solidity >=0.5.0 <0.6.0;

contract GameChanger {

    uint ChallengeCount = 0;

    struct Challenge {
        string name;
        address host;
        string description;
        uint starttime;
        uint timelimit;
        uint reward;
        uint challengercount;
        address[] challengers;
    }

    Challenge[] public challenges;

    function createChallenge(string memory name, string memory description, 
        uint timelimit, uint reward) public { 

        ChallengeCount++;
        address host = msg.sender;
        uint starttime = now;
        uint challengercount = 0;
        challenges.push(Challenge(name, host, description, starttime,                         
        timelimit, reward, challengercount, new address[](0)));
    }

    function acceptChallenge(uint ChallengeCount) public { 

        if (now <= ((challenges[ChallengeCount].starttime)  + 24)) {
            challenges[ChallengeCount].challengers.push(msg.sender);
            challenges[ChallengeCount].challengercount++;
            uint id = challenges[ChallengeCount].challengercount;
            registration[id] = msg.sender;
        }
    }
}

I am trying to push data to an address array within a struct array. There are no errors, however, when I check the storage of the array in my contract in Ganache, it remains empty. Is there something wrong with my code? Or is it not meant to display in Ganache? And if the data doesn't display in Ganache, does that mean it isn't being stored anywhere?

My code is provided below. I am trying to push data to the address array challengers in struct array challenges through function acceptChallenge.

pragma solidity >=0.5.0 <0.6.0;

contract GameChanger {

uint ChallengeCount = 0;

struct Challenge {
string name;
address host;
string description;
uint starttime;
uint timelimit;
uint reward;
uint challengercount;
address[] challengers;
}

Challenge[] public challenges;

function createChallenge(string memory name, string memory description, uint timelimit, uint reward) public {
ChallengeCount++;
address host = msg.sender;
uint starttime = now;
uint challengercount = 0;
challenges.push(Challenge(name, host, description, starttime, timelimit, reward, challengercount, new address[](0)));
}

function acceptChallenge(uint ChallengeCount) public {
if (now <= ((challenges[ChallengeCount].starttime)  + 24)) {
challenges[ChallengeCount].challengers.push(msg.sender);
challenges[ChallengeCount].challengercount++;
uint id = challenges[ChallengeCount].challengercount;
registration[id] = msg.sender;
}
}

I am trying to push data to an address array within a struct array. There are no errors, however, when I check the storage of the array in my contract in Ganache, it remains empty. Is there something wrong with my code? Or is it not meant to display in Ganache? And if the data doesn't display in Ganache, does that mean it isn't being stored anywhere?

My code is provided below. I am trying to push data to the address array challengers in struct array challenges through function acceptChallenge.

pragma solidity >=0.5.0 <0.6.0;

contract GameChanger {

    uint ChallengeCount = 0;

    struct Challenge {
        string name;
        address host;
        string description;
        uint starttime;
        uint timelimit;
        uint reward;
        uint challengercount;
        address[] challengers;
    }

    Challenge[] public challenges;

    function createChallenge(string memory name, string memory description, 
        uint timelimit, uint reward) public { 

        ChallengeCount++;
        address host = msg.sender;
        uint starttime = now;
        uint challengercount = 0;
        challenges.push(Challenge(name, host, description, starttime,                         
        timelimit, reward, challengercount, new address[](0)));
    }

    function acceptChallenge(uint ChallengeCount) public { 

        if (now <= ((challenges[ChallengeCount].starttime)  + 24)) {
            challenges[ChallengeCount].challengers.push(msg.sender);
            challenges[ChallengeCount].challengercount++;
            uint id = challenges[ChallengeCount].challengercount;
            registration[id] = msg.sender;
        }
    }
}
Source Link
Loading