I wanted to verify that for a connected ring $k$ (i.e. a ring with connected spectrum, or equivalently without idempotents other than $0$ and $1$) the group of $k$-endomorphisms of the multiplicative group $\mathbf{G}_m$ over $k$ can be identified with $\mathbf{Z}$. I have an outline for this (at least for $k$ local) which suggests that I treat the case of a field first, then extend it to Artin local rings by induction on length, then to complete Noetherian local rings, etc.. But the very simple argument I have for the case of a field seems to me to be completely general, which makes me believe I must be making a mistake or overlooking something.
Using the definition of the multiplication for $\mathbf{G}_m$, it can be shown that $f(t)\in k[t,t^{-1}]^\times$ ($k[t,t^{-1}]$ being the coordinate ring of $\mathbf{G}_m$) yields a $k$-homomorphism if and only if $f(xy)=f(x)f(y)$ in $k[x,y,x^{-1},y^{-1}]$. Note that $\mathbf{G}_m(\mathbf{G}_m)=\mathrm{Hom}_{k-\mathrm{Alg}}(k[t,t^{-1}],k[t,t^{-1}])=k[t,t^{-1}]^\times$ via $\varphi\mapsto\varphi(t)$, so $f$ must be a unit to have a $k$-morphism at all.
Now, if I write $f=\sum_n a_n t^n$, $n$ ranging over all of $\mathbf{Z}$, then the equation $f(xy)=f(x)f(y)$ seems to give me
$\sum_n a_n x^n y^n=\sum_{n,m} a_n a_mx^n y^m$.
Because $f$ is a unit, and in particular non-zero, some $a_n$ must be non-zero, say $a_{n_0}\neq 0$. Equating coefficients of monomials in the equation above (using that the monomials $x^n y^m$ for $n,m\in\mathbf{Z}$ form a $k$-basis for $k[x,y,x^{-1},y^{-1}]$) we get $a_n^2=a_n$ for all $n$ and $a_na_m=0$ for $n\neq m$. Since $k$ is connected and $a_{n_0}\neq 0$, $a_{n_0}^2=a_{n_0}$ forces $a_{n_0}=1$. Then, for any $m\neq n_0$, $0=a_{n_0}a_m=a_m$, so $f(t)=t^{n_0}$.
Is there anything wrong with this argument? Have I used somewhere that $k$ is a field?
Incidentally, it also seems like the equation $f(xy)=f(x)f(y)$ for $f\neq 0$ implies that $f$ is a unit, since all I used in deducing that $f(t)=t^{n_0}$ for some $n_0$ was that $f$ was non-zero.