How can I show the uniqueness of homomorphism? Let $R$ be a commutative ring and let $k(x)$ be a fixed polynomial in $R[x]$.
Prove that there exists a unique homomorphism $\varphi:R[x]\rightarrow R[x]$ such that
$\varphi(r)=r\;\mathrm{for\; all\;}r\in R\quad\mathrm{and}\qquad\varphi(x)=k(x)$
and I found such ring homomorphism as follows:
For any $f(x)=\sum_{i=0}^{n}a_{i}x^{i}\in R[x]$, 
 define  $\varphi(f(x))=\sum_{i=0}^{n}a_{i}\left[k(x)\right]^{i}$
Then I can easily show that $\varphi(r)=r$  $\mathrm{and}$ $\varphi(x)=k(x)$
But it's hard for me to prove the uniqueness..

(Note: all rings involved are unital)
This is a special case of $R[x]$ being free commutative $R$-algebra over one element. I will explain precisely what I mean and if you never heard of the concept, think of vector spaces: you can define unique linear operator just by setting the values on a base and extending by linearity. This is pretty much the same.

Claim: Let $A$ be a commutative $R$-algebra ($R$-module that is a ring) and let $a\in A$. Then there is a unique algebra homomorphism
  $\varphi\colon R[x]\to A$ ($R$-linear map that is multiplicative) such
  that $\varphi(1) = 1$, $\varphi(x) = a$.

Proof. We define $\varphi$ precisely how you did it: $$\varphi(\sum r_nx^n) = \sum r_n a^n$$ It's straightforward verification that this is $R$-linear and multiplicative. Let $\psi\colon R[x] \to A$ be algebra homomorphism such that $\psi(1) = 1$, $\psi(x) = a$. Then we have $$\psi(\sum r_nx^n) = \sum\psi(r_nx^n)=\sum r_n\psi(x)^n=\sum r_na^n = \varphi(\sum r_nx^n)$$ and thus the uniqueness is proved.
To get your claim, set $A=R[x]$ and $a = k(x)$.
