A universal construction of the field of fractions of an integral domain? Let $R$ be an integral domain and For a field $\hat R$ consider the following : There is an injective ring homomorphism $i:R \to \hat R$ such that for any field $F$ and any injective ring homomorphism $f:R \to F$ , there is unique injective field homomorphism $\hat f :\hat R \to F$ such that $\hat f \circ i=f$ . Then is it true that any two fields  $\hat R , {\hat R}'$ satisfying the previous property , are field isomorphic ? What if we drop injective conditions from $f , \hat f$ , then are the objects $\hat R  , {\hat R}'$ still isomorphic ? This was motivated from the construction of field of fractions of an integral domain . Now what is a similar universal construction of the localization of general commutative ring with unity ? 
 A: In what follows all rings will be commutative with $1$ and all ring morphisms will send $1$ to $1$. Let $A$ be a ring with $1$ and $S$ a multiplicatively closed subset of $A$ (It is a fortiori stable by the empty product so that it contains $1$.) If $A$ is a ring, $A^{\times}$ is the group of invertible elements of $A$.
Consider the following "universal problem" : find a ring $A'$ endowed with a ring morphism $i : A \to A'$ such that $i(S)\subseteq A'^{\times}$ and such that the following universal property is satisfied : for each ring morphism $f : A\to B$ such that $f(S)\subseteq B^{\times}$, there exists a unique morphism $F : A'\to B$ such that $F\circ i = f$. It is easy to remark that if such a pair $(A',i)$ exists, it unique up to a unique isomorphism. (See my answer here for what is a universal property.)
Now, how to construct $A'$ and $i$ ? Consider the set $A\times S$ and define a relation $\mathscr{R}$ on it as follows : for all $(a,s),(a',s')\in A\times S$, one sets $(a,s)\;\mathscr{R}\;(a',s')$ if and only if there exists $s''\in S$ such that $s''(as'-a's) = 0$. This is an equivalence relation. Note $\frac{a}{s}$ the class of $(a,s)\in A\times S$, and note $S^{-1} A$ the quotient set $(A\times S) / \mathscr{R}$. Then you can see that defining $\frac{a}{s}+\frac{a'}{s'} := \frac{as'+a's}{ss'}$ and $\frac{a}{s} \frac{a'}{s'} := \frac{aa'}{ss'}$ makes sense. Then $\frac{0}{1}$ is neutral for $+$ and $\frac{1}{1}$ is neutral for the product. So finally you have a ring $A'=S^{-1} A$, and you can see that the map $i : A\to S^{-1} A$ defined by $a\mapsto \frac{a}{1}$ is a morphism of rings satisfying the required property and whose kernel is $\{a\in A\;|\;\exists s\in S, sa = 0\}$.Finally, you can prove that $(S^{-1} A, i)$ satisfies the universal property. This answers your last question.
$S^{-1}A$ is called the localization of $A$ with respect to the multiplicatively closed subset $S$ : it is the smallest ring "in" which all elements of $S$ are invertible. If $A$ is a domain and $S = A\backslash\{0\}$, the ring $S^{-1}A$ is simply the fractions field of $A$. This answers your first question, as your $f : R\to F$ (with $R$ a domain) is injective if and only if $f(R^{\times})\subseteq F^{\times}$.) Other most common examples (now $A$ is not a domain anymore) are : $S = \{f^n\;|\; n\in\mathbf{N}\}$ for an $f\in A$, in which case $S^{-1} A := A_{(f)}$ or $A_f$ depending on the authors : this is a the "smallest" ring "in" which $f$ is invertible, and it is isomorphic to $A[T]/(fT-1)$. (Note that $A_{(0)} = 0$.) If $\mathfrak{p}$ is a prime ideal of $A$ then $S = A\backslash\mathfrak{p}$ is multiplicatively closed and $S^{-1} A := A_{\mathfrak{p}}$ is called the localization of $A$ at the prime ideal $\mathfrak{p}$. Note that if $S$ is a multiplicatively closed subset of $A$ and if $S'$ is the set of element of $A$ that divide an element of $S$, then $S'$ is multiplicatively closed and there is a canonical isomorphism ${S'}^{-1} A \to {S}^{-1} A$.
Now, regarding your second question, if $\widehat{f}$ such that $\widehat{f}\circ i = f$ exists, $\widehat{f}$ is a morphism of fields and is automatically injective, and as $i$ is injective, so is $f$. Moral : a morphism from a domain to a field can be extended to the field of fractions of the domain if and only if it is injective.
Bonus. Finally, you can in fact repeat all what preceeds when you replace $A$ by an $A$-module $M$ and when you replace the universal problem by : find an $A$-module $M'$ endowed with a $A$-linear map $i : M\to M'$ such that homotheties with ratio in $S$ are automorphisms of $M'$ and such that the following universal property is satisfied : for each $A$-linear map $f : M\to P$ from $M$ into an $A$-module $P$ in which homotheties with ratio in $S$ are automorphisms, where exists a unique $A$-linear map $F : M'\to P$ such that $F\circ i = f$. One notes $M' := S^{-1} M$ and it is called the localization of $M$ with respect to the multiplicatively closed subset $S$ of $A$. Morever, $S^{-1} M$ is naturally a $S^{-1} A$-module. All examples and related notations seen previously translate to this case.
A: Consider the category of integral domains and injections. This has a subcategory given by fields and injections. In fact this is a reflective subcategory: the left adjoint of the inclusion is precisely the field of fractions, which just says that the field of fractions has the universal property you want it to, and then uniqueness follows because objects satisfying universal properties are always unique by the Yoneda lemma. The proof is straightforward. 
Using injections here is crucial. For example, $\mathbb{Z}$ admits both a map $\mathbb{Z} \to \mathbb{Q}$ and a map $\mathbb{Z} \to \mathbb{F}_2$, and there is no map from $\mathbb{Z}$ to a field through which both of these maps factor. 
