I am building a event application using Ethereum and smart contracts.

Contract Event.sol

pragma solidity ^0.4.4;

contract Event {

uint32 currentMaxNumOfEvents=0;
struct eventDetail{
uint32  eventId;
address  eventHost;
string  eventName;
uint32  noOfDaysToRegsiter;
uint32  maxMembers;
address[]  memberAddress;
mapping(uint32 => eventDetail) public events;
function joinEvent(uint32 selectedEventId)public{
    require(events[selectedEventId].memberAddress.length < events[selectedEventId].maxMembers);
function createEvent(string eventName,uint32 noOfdays,uint32 maxMembers) public returns (uint){
    currentMaxNumOfEvents += 1;
    events[currentMaxNumOfEvents].eventId= currentMaxNumOfEvents;
    events[currentMaxNumOfEvents].eventHost =msg.sender;
    events[currentMaxNumOfEvents].eventName = eventName;
    events[currentMaxNumOfEvents].noOfDaysToRegsiter = noOfdays;
    events[currentMaxNumOfEvents].maxMembers = maxMembers;
    return events[currentMaxNumOfEvents].eventId;



What am i doing wrong? And how can I make people pay to create event?

  • 1
    please provide more information like what client are you using geth/testrpc? local chain or testnet? what is the function call that says "gas required exceeds block limit : 300000" – Crema Nov 3 '17 at 14:59
  • I am using ropsen tesnet with remix... It is shown when I click create after run – SHA256 Nov 3 '17 at 15:11

I don't see any problem creating an event using Remix via the createEvent function - what action are you performing that is resulting in this error?

One problem that I can foresee with your contract is the use of an array to store the list of addresses of the members that have signed up.

I assume that there's another function somewhere, where you are looping over the array of memberAddress and that is where you are finding that it requires more gas than the block limit?

You might want to look at some of the other questions related to arrays in Solidity; such as this one for ways to store the data that are more appropriate.

Perhaps check all of the settings in MetaMask, I am able to deploy the contract to the Ropsten testnet:

enter image description here

The deployed contract - with an event created - can be seen here

I entered the following parameters to the createEvent function

"some really long event name", 10, 100

I notice that when I called the joinEvent function with the parameter 0 that I got a similar error:

transact to browser/Untitled.sol:Event.joinEvent errored: Gas required exceeds limit: 3000000.  An important gas estimation might also be the sign of a problem in the contract code. Please check loops and be sure you did not sent value to a non payable function (that's also the reason of strong gas estimation). 

I had a look at your code and I noticed that when you create an event that you do something that I found peculiar, you start your array index at 1 and not 0:

currentMaxNumOfEvents += 1;
events[currentMaxNumOfEvents].eventId= currentMaxNumOfEvents;

The contract then errored out with this out of gas error, in the joinEvent function, because it fails on this test


There is no events[0].memberAddress to call length on.

I suspect that the reason that you are getting the out of gas error is that, similarly, the parameters that you are entering to the function call are incorrect - try the ones that I used successfully.

| improve this answer | |
  • No... I am not using any loops.. this is all the code i am trying to run.. I am a total noob.. I compiled the code in remix and clock run... the left side i can see a create button... as gas limit gas price etc.. when i click create button this happens – SHA256 Nov 3 '17 at 15:13
  • I am using repson testnet in metamask – SHA256 Nov 3 '17 at 15:15
  • See if my updated answer helps - I suspect that it's the parameters that you are entering to the function that are causing the problem; if you don't get a MetaMask pop-up then it's definitely before the transaction is submitted to the network. – SteveJaxon Nov 3 '17 at 16:24
  • yeah changed the code and worked!! – SHA256 Nov 3 '17 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.