diff --git a/libdevcore/CommonJS.h b/libdevcore/CommonJS.h
index 81a0ac86e..cc487d54c 100644
--- a/libdevcore/CommonJS.h
+++ b/libdevcore/CommonJS.h
@@ -103,7 +103,9 @@ inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); }
 
 inline int jsToInt(std::string const& _s)
 {
-	return std::stoi(_s, nullptr, 16);
+	if (_s.size() > 2 && _s.substr(0, 2).compare("0x") == 0)
+		return std::stoi(_s, nullptr, 16);
+	return std::stoi(_s, nullptr, 10);
 }
 
 inline std::string jsToDecimal(std::string const& _s)