I'm not sure what the problem is, but in general I find nxtt (the default typewriter font used with NewTX) not particularly attractive and too big:

Usually typewriter type is a bit smaller then Roman type.
You can do it with some trickery: use the nott option and define later the same font family, but scaled at 90%.
\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{amsmath,amssymb}
\usepackage{lipsum}
\usepackage[nott]{newtxtext}
\usepackage{newtxmath}
\usepackage{listings}
\usepackage{lstautogobble}
\makeatletter
\AtBeginDocument{%
\providecommand{\ntx@scaled}{}%
\renewcommand{\ntx@scaled}{s*[0.9]}%
\renewcommand{\ttdefault}{ntxtt}%
}
\makeatother
\lstdefinestyle{mystyle}
{
basicstyle=\ttfamily,
frame=single,
breaklines,
columns=fullflexible,
breakindent=1.2em,
breakatwhitespace,
escapeinside={(}{)},
}
\begin{document}
abc\texttt{abc}
\begin{lstlisting}[style=mystyle,autogobble,xleftmargin=1.1mm,xrightmargin=2.5pt]
function hello_world(,)(uint a, uint b, uint c, uint d, uint e, uint f) public returns bool {
uint256 amount = 100
return true;
}
\end{lstlisting}
\lipsum*[2]
\end{document}

Alternatively, use an altogether different typewriter font.
\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{amsmath,amssymb}
\usepackage{lipsum}
\usepackage[nott]{newtxtext}
\usepackage{newtxmath}
\usepackage[scale=0.95]{zi4}
\usepackage{listings}
\usepackage{lstautogobble}
\lstdefinestyle{mystyle}
{
basicstyle=\ttfamily,
frame=single,
breaklines,
columns=fullflexible,
breakindent=1.2em,
breakatwhitespace,
escapeinside={(}{)},
}
\begin{document}
abc\texttt{abc}
\begin{lstlisting}[style=mystyle,autogobble,xleftmargin=1.1mm,xrightmargin=2.5pt]
function hello_world(,)(uint a, uint b, uint c, uint d, uint e, uint f) public returns bool {
uint256 amount = 100
return true;
}
\end{lstlisting}
\lipsum*[2]
\end{document}

Last, but not least, you can decide to reduce the fontsize for a particular listing (or all of them) by setting
basicstyle=\ttfamily\small
or even \footnotesize.
\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{amsmath,amssymb}
\usepackage{lipsum}
\usepackage[nott]{newtxtext}
\usepackage{newtxmath}
\usepackage[scale=0.95]{zi4}
\usepackage{listings}
\usepackage{lstautogobble}
\lstdefinestyle{mystyle}
{
basicstyle=\ttfamily,
frame=single,
breaklines,
columns=flexible,
breakindent=1.2em,
breakatwhitespace,
escapeinside={(}{)},
}
\lstdefinestyle{mystylesmaller}
{
style=mystyle,
basicstyle=\ttfamily\small,
}
\begin{document}
abc\texttt{abc}
\begin{lstlisting}[style=mystyle,autogobble,xleftmargin=1.1mm,xrightmargin=2.5pt]
function hello_world(,)(uint a, uint b, uint c, uint d, uint e, uint f) public returns bool {
uint256 amount = 100
return true;
}
\end{lstlisting}
\begin{lstlisting}[style=mystylesmaller,autogobble,xleftmargin=1.1mm,xrightmargin=2.5pt]
function hello_world(,)(uint a, uint b, uint c, uint d, uint e, uint f) public returns bool {
uint256 amount = 100
return true;
}
\end{lstlisting}
\lipsum*[2]
\end{document}

lstlistingandlstinputlisting? where can I uselstinputlistinginstead ? – alper Oct 03 '22 at 11:09zi4); about the font size, you can take a case by case decision. You can use\lstinputlistingwhen you want to input a file, rather than having the code in the.texfile. – egreg Oct 03 '22 at 12:24\linespread{0.9}in front of\ttfamily– egreg Oct 04 '22 at 17:25