I've had an issue with my first solidity contract whereby sometimes transactions will work and other times I'll get "out of gas" errors. I believe after much research I've pinpointed this problem to the contract making extensive use of block.timestamp and "now" for pseudo-RNG purposes (which I'm aware of the limitations). Such function calls I hear make the exact gas required highly unpredictable.
Unfortunately during my testing on Ropstein, Metamask seems to fail about 30% of the time in predicting the correct amount of gas, and I run out of gas. I get no such errors when testing on testrpc or JavaVM (since obviously gas isn't an issue here).
I've thought that if I could somehow code in solidity a way to tell metamask that it should send a fixed amount "extra" gas, or if I could even define the exact gas amount to send, that these issues might be avoidable. If this isn't possible, how do other dapps get around using block.timestamp and metamask without running into these out of gas errors sometimes?
It's absolutely NOT a solution that the client must manually change their gas for my contract, since the dapp is designed to work flawlessly for every user. A lot of consumer engagement will no doubt be lost if I require my users to specify the gas limit in metamask themselves.
Is there any way around this issue whereby the user doesn't have to do anything?