Looking for some help with a contract I am writing. I have started breaking parts up into other contracts and inheriting them so all of the functions are available from the root contract, like contract1 is contract2. I am now getting a revert error when i run truffle test, specifically where it deploys a new contract1 and it happens when i try to add 1 more function anywhere. it can be anything function test() returns (bool) and it will fail immediately with revert. if I remove the new function my tests run fine. So it seems im hitting some kind of limit on the contract. in my truffle.js I have set gas: 4698712,
gasPrice: 25000000000 increasing that does nothing
Sep 14, 2018, 4:11 AM
Im seeing Error: VM Exception while processing transaction: revert
yes because if I copy an existing function and say myfunction2() no matter how simple it says revert
if I remove the new function then it works
its so strange
Im using truffle how do you mean debug it?
i am using the truffle develop console
theres like a bunch of zeppelin contracts and stuff inherited I think I may have found it, on the .deployContract('Test', '1', 1000000, {from: accounts[0], gas: 3000000});
I bet that is where I need to up the gas
annnnnd fixed!
thanks your comment made me go check out the deploy line of code 😄
what would be the best way to check now against a specific date, would you just lookup unix timestamp for that date (which I think is the same time since 1970 or whatever) and then just go if(now >= timestamp) ?
like I want to create an expiry
date
Sep 14, 2018, 5:16 AM
i supouse timestamp is the exp. date?
then yes.. I would do it that way
Sep 14, 2018, 5:25 AM
ok perfect, I was also checking out how to just add days. I saw some contracts doing 24 * 60 *60 * 24 for adding days to the now variable
but I also see in the docs solidity has a days value
is it legit to jsut say expiry = now + 5 days; ?
and then if(now >= expiry)
that seems cleaner
Sep 14, 2018, 5:27 AM
Yes, time units are globaly available variables.. ie seconds, minutes, hours, days, weeks and years.
Sep 14, 2018, 5:34 AM
👍
now were cooking with gas
get it!? little ethereum joke there...
Sep 14, 2018, 5:35 AM
😝
Sep 14, 2018, 5:36 AM
😋👍
Sep 14, 2018, 6:07 AM
ok last question if anyones awake. If I have multiple condition require(cond1 && cond2) how do I say both conditions have to be true vs cond1 OR cond2 being true. I believe as it is written if cond1 is false it will fail even if there not both true. in my case if cond1 is false and condition2 is false then everything is fine I dont want to revert, but if cond1 is true then condition2 needs to be evaluated. should I just wrap it in an if(cond1){ require(cond2) } ?? or can it be written using 1 require() ?
if that even makes any sense at all tbh I cant even see straight haha
I know right lol
yes well if cond1 is false cond2 doesnt even matter
but if cond1 is true they both need to be true
but then if cond1 is false wouldnt if revert ?
so i dont it to
dont want it to if cond1 is false
if(cond1){
require(cond2);
}
require(cond2);
}
thats what i want
so cond1 can be false but if its true then cond2 also has to be true
no because if cond1 is true and cond2 is false it has to revert
that would pass if either is true
Im just gonna use if(cond1){
require(cond2);
} lol
require(cond2);
} lol
no they can both be true or cond1 can be false
IVe also wway overcomplicated my question and explanations cause im super tired lol
Sep 14, 2018, 7:21 AM
So cond 1 does not matter?
require(cond2);
Sep 14, 2018, 7:24 AM
This makes it more readable, so I'd definitely prefer this over any micro-optimization. Keep it simple and expressive.
Also helps to understand your own code a year on from now. ;)
If you intuitively would want to write a comment to explain what a few lines of code do, you should probably not write it that way, IMHO. BTW, YMMV. 😉
Sep 14, 2018, 1:53 PM