diff --git a/substrate/substrate/codec/derive/src/lib.rs b/substrate/substrate/codec/derive/src/lib.rs
index 5f8b67901e2a2927cee0c54a8db3e0f649d69054..1bf3aebe7522a09a624ec36694524b36588c9328 100644
--- a/substrate/substrate/codec/derive/src/lib.rs
+++ b/substrate/substrate/codec/derive/src/lib.rs
@@ -17,7 +17,6 @@
 //! Derives serialization and deserialization codec for complex structs for simple marshalling.
 
 #![cfg_attr(not(feature = "std"), no_std)]
-//#![cfg_attr(not(feature = "std"), feature(alloc))]
 
 extern crate proc_macro;
 extern crate proc_macro2;
diff --git a/substrate/substrate/rpc-servers/src/lib.rs b/substrate/substrate/rpc-servers/src/lib.rs
index 8fcdea851f52766b6c886e1829eb844cc163ecaf..530d637f096d0e0c98bdbc934f64d3e31c084279 100644
--- a/substrate/substrate/rpc-servers/src/lib.rs
+++ b/substrate/substrate/rpc-servers/src/lib.rs
@@ -31,7 +31,7 @@ extern crate substrate_runtime_primitives;
 extern crate log;
 
 use std::io;
-use substrate_runtime_primitives::traits::Block as BlockT;
+use substrate_runtime_primitives::traits::{Block as BlockT, NumberFor};
 
 type Metadata = apis::metadata::Metadata;
 type RpcHandler = pubsub::PubSubHandler<Metadata>;
@@ -49,7 +49,7 @@ pub fn rpc_handler<Block: BlockT, ExHash, PendingExtrinsics, S, C, A, Y>(
 	ExHash: Send + Sync + 'static + substrate_runtime_primitives::Serialize + substrate_runtime_primitives::DeserializeOwned,
 	PendingExtrinsics: serde::Serialize + serde::de::DeserializeOwned + Send + Sync + 'static,
 	S: apis::state::StateApi<Block::Hash, Metadata=Metadata>,
-	C: apis::chain::ChainApi<Block::Hash, Block::Header, Block::Extrinsic, Metadata=Metadata>,
+	C: apis::chain::ChainApi<Block::Hash, Block::Header, NumberFor<Block>, Block::Extrinsic, Metadata=Metadata>,
 	A: apis::author::AuthorApi<ExHash, Block::Extrinsic, PendingExtrinsics, Metadata=Metadata>,
 	Y: apis::system::SystemApi,
 {
diff --git a/substrate/substrate/rpc/src/chain/mod.rs b/substrate/substrate/rpc/src/chain/mod.rs
index bae10a50c040928a73c3acc080e50ddc23e3e159..7866ae3ef2cd754d3aa8ae8ace8aab8d2d4f9b24 100644
--- a/substrate/substrate/rpc/src/chain/mod.rs
+++ b/substrate/substrate/rpc/src/chain/mod.rs
@@ -19,13 +19,12 @@
 use std::sync::Arc;
 
 use client::{self, Client, BlockchainEvents};
-use jsonrpc_macros::pubsub;
+use jsonrpc_macros::{pubsub, Trailing};
 use jsonrpc_pubsub::SubscriptionId;
-use jsonrpc_macros::Trailing;
 use rpc::Result as RpcResult;
 use rpc::futures::{stream, Future, Sink, Stream};
 use runtime_primitives::generic::{BlockId, SignedBlock};
-use runtime_primitives::traits::Block as BlockT;
+use runtime_primitives::traits::{Block as BlockT, Header, NumberFor};
 use runtime_version::RuntimeVersion;
 use tokio::runtime::TaskExecutor;
 use primitives::{KeccakHasher, RlpCodec};
@@ -40,20 +39,22 @@ use self::error::Result;
 
 build_rpc_trait! {
 	/// Polkadot blockchain API
-	pub trait ChainApi<Hash, Header, Extrinsic> {
+	pub trait ChainApi<Hash, Header, Number, Extrinsic> {
 		type Metadata;
 
 		/// Get header of a relay chain block.
 		#[rpc(name = "chain_getHeader")]
-		fn header(&self, Hash) -> Result<Option<Header>>;
+		fn header(&self, Trailing<Hash>) -> Result<Option<Header>>;
 
 		/// Get header and body of a relay chain block.
 		#[rpc(name = "chain_getBlock")]
-		fn block(&self, Hash) -> Result<Option<SignedBlock<Header, Extrinsic, Hash>>>;
+		fn block(&self, Trailing<Hash>) -> Result<Option<SignedBlock<Header, Extrinsic, Hash>>>;
 
-		/// Get hash of the head.
-		#[rpc(name = "chain_getHead")]
-		fn head(&self) -> Result<Hash>;
+		/// Get hash of the n-th block in the canon chain.
+		///
+		/// By default returns latest block hash.
+		#[rpc(name = "chain_getBlockHash", alias = ["chain_getHead", ])]
+		fn block_hash(&self, Trailing<Number>) -> Result<Option<Hash>>;
 
 		/// Get the runtime version.
 		#[rpc(name = "chain_getRuntimeVersion")]
@@ -102,23 +103,28 @@ impl<B, E, Block> Chain<B, E, Block> where
 	}
 }
 
-impl<B, E, Block> ChainApi<Block::Hash, Block::Header, Block::Extrinsic> for Chain<B, E, Block> where
+impl<B, E, Block> ChainApi<Block::Hash, Block::Header, NumberFor<Block>, Block::Extrinsic> for Chain<B, E, Block> where
 	Block: BlockT + 'static,
 	B: client::backend::Backend<Block, KeccakHasher, RlpCodec> + Send + Sync + 'static,
 	E: client::CallExecutor<Block, KeccakHasher, RlpCodec> + Send + Sync + 'static,
 {
 	type Metadata = ::metadata::Metadata;
 
-	fn header(&self, hash: Block::Hash) -> Result<Option<Block::Header>> {
+	fn header(&self, hash: Trailing<Block::Hash>) -> Result<Option<Block::Header>> {
+		let hash = self.unwrap_or_best(hash)?;
 		Ok(self.client.header(&BlockId::Hash(hash))?)
 	}
 
-	fn block(&self, hash: Block::Hash) -> Result<Option<SignedBlock<Block::Header, Block::Extrinsic, Block::Hash>>> {
+	fn block(&self, hash: Trailing<Block::Hash>) -> Result<Option<SignedBlock<Block::Header, Block::Extrinsic, Block::Hash>>> {
+		let hash = self.unwrap_or_best(hash)?;
 		Ok(self.client.block(&BlockId::Hash(hash))?)
 	}
 
-	fn head(&self) -> Result<Block::Hash> {
-		Ok(self.client.info()?.chain.best_hash)
+	fn block_hash(&self, number: Trailing<NumberFor<Block>>) -> Result<Option<Block::Hash>> {
+		Ok(match number.into() {
+			None => Some(self.client.info()?.chain.best_hash),
+			Some(number) => self.client.header(&BlockId::number(number))?.map(|h| h.hash()),
+		})
 	}
 
 	fn runtime_version(&self, at: Trailing<Block::Hash>) -> Result<RuntimeVersion> {
@@ -129,8 +135,8 @@ impl<B, E, Block> ChainApi<Block::Hash, Block::Header, Block::Extrinsic> for Cha
 	fn subscribe_new_head(&self, _metadata: Self::Metadata, subscriber: pubsub::Subscriber<Block::Header>) {
 		self.subscriptions.add(subscriber, |sink| {
 			// send current head right at the start.
-			let header = self.head()
-				.and_then(|hash| self.header(hash))
+			let header = self.block_hash(None.into())
+				.and_then(|hash| self.header(hash.into()))
 				.and_then(|header| {
 					header.ok_or_else(|| self::error::ErrorKind::Unimplemented.into())
 				})
diff --git a/substrate/substrate/rpc/src/chain/tests.rs b/substrate/substrate/rpc/src/chain/tests.rs
index 1f32705f8037b0f45f014fabf0b8791f2bc0bb7d..0be58b2b4be8bb74dce3b27c1f81f43b04651544 100644
--- a/substrate/substrate/rpc/src/chain/tests.rs
+++ b/substrate/substrate/rpc/src/chain/tests.rs
@@ -29,8 +29,9 @@ fn should_return_header() {
 		client: Arc::new(test_client::new()),
 		subscriptions: Subscriptions::new(remote),
 	};
+
 	assert_matches!(
-		client.header(client.client.genesis_hash()),
+		client.header(Some(client.client.genesis_hash()).into()),
 		Ok(Some(ref x)) if x == &Header {
 			parent_hash: 0.into(),
 			number: 0,
@@ -41,7 +42,18 @@ fn should_return_header() {
 	);
 
 	assert_matches!(
-		client.header(5.into()),
+		client.header(None.into()),
+		Ok(Some(ref x)) if x == &Header {
+			parent_hash: 0.into(),
+			number: 0,
+			state_root: x.state_root.clone(),
+			extrinsics_root: "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421".into(),
+			digest: Default::default(),
+		}
+	);
+
+	assert_matches!(
+		client.header(Some(5.into()).into()),
 		Ok(None)
 	);
 }
@@ -63,12 +75,26 @@ fn should_return_a_block() {
 
 	// Genesis block is not justified, so we can't query it?
 	assert_matches!(
-		api.block(api.client.genesis_hash()),
+		api.block(Some(api.client.genesis_hash()).into()),
 		Ok(None)
 	);
 
 	assert_matches!(
-		api.block(block_hash),
+		api.block(Some(block_hash).into()),
+		Ok(Some(ref x)) if x.block == Block {
+			header: Header {
+				parent_hash: api.client.genesis_hash(),
+				number: 1,
+				state_root: x.block.header.state_root.clone(),
+				extrinsics_root: "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421".into(),
+				digest: Default::default(),
+			},
+			extrinsics: vec![],
+		}
+	);
+
+	assert_matches!(
+		api.block(None.into()),
 		Ok(Some(ref x)) if x.block == Block {
 			header: Header {
 				parent_hash: api.client.genesis_hash(),
@@ -82,9 +108,49 @@ fn should_return_a_block() {
 	);
 
 	assert_matches!(
-		api.block(5.into()),
+		api.block(Some(5.into()).into()),
+		Ok(None)
+	);
+}
+
+#[test]
+fn should_return_block_hash() {
+	let core = ::tokio::runtime::Runtime::new().unwrap();
+	let remote = core.executor();
+
+	let client = Chain {
+		client: Arc::new(test_client::new()),
+		subscriptions: Subscriptions::new(remote),
+	};
+
+	assert_matches!(
+		client.block_hash(None.into()),
+		Ok(Some(ref x)) if x == &client.client.genesis_hash()
+	);
+
+
+	assert_matches!(
+		client.block_hash(Some(0u64).into()),
+		Ok(Some(ref x)) if x == &client.client.genesis_hash()
+	);
+
+	assert_matches!(
+		client.block_hash(Some(1u64).into()),
 		Ok(None)
 	);
+
+	let block = client.client.new_block().unwrap().bake().unwrap();
+	client.client.justify_and_import(BlockOrigin::Own, block.clone()).unwrap();
+
+	assert_matches!(
+		client.block_hash(Some(0u64).into()),
+		Ok(Some(ref x)) if x == &client.client.genesis_hash()
+	);
+	assert_matches!(
+		client.block_hash(Some(1u64).into()),
+		Ok(Some(ref x)) if x == &block.hash()
+	);
+
 }
 
 #[test]
diff --git a/substrate/substrate/rpc/src/helpers.rs b/substrate/substrate/rpc/src/helpers.rs
new file mode 100644
index 0000000000000000000000000000000000000000..dca1a45db563ddf0103b81e4ff230ab728824f8a
--- /dev/null
+++ b/substrate/substrate/rpc/src/helpers.rs
@@ -0,0 +1,25 @@
+// Copyright 2018 Parity Technologies (UK) Ltd.
+// This file is part of Substrate.
+
+// Substrate is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Substrate is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Substrate.  If not, see <http://www.gnu.org/licenses/>.
+
+/// Unwraps the trailing parameter or falls back with the closure result.
+pub fn unwrap_or_else<F, H, E>(or_else: F, optional: ::jsonrpc_macros::Trailing<H>) -> Result<H, E> where
+	F: FnOnce() -> Result<H, E>,
+{
+	match optional.into() {
+		None => or_else(),
+		Some(x) => Ok(x),
+	}
+}
diff --git a/substrate/substrate/rpc/src/lib.rs b/substrate/substrate/rpc/src/lib.rs
index 3f76c1b5ddba1bf643895f6836bbb7f742763fb8..760b1ca5672630bfbd2dde7478ae913e3f89c959 100644
--- a/substrate/substrate/rpc/src/lib.rs
+++ b/substrate/substrate/rpc/src/lib.rs
@@ -46,6 +46,7 @@ extern crate substrate_test_client as test_client;
 extern crate rustc_hex;
 
 mod errors;
+mod helpers;
 mod subscriptions;
 
 pub mod author;
diff --git a/substrate/substrate/rpc/src/state/mod.rs b/substrate/substrate/rpc/src/state/mod.rs
index 28aa01710955c3def75e19054caf79d4c4ce3faf..80369326de047ccce6cb7054f9b437c06dc0f862 100644
--- a/substrate/substrate/rpc/src/state/mod.rs
+++ b/substrate/substrate/rpc/src/state/mod.rs
@@ -101,15 +101,12 @@ impl<B, E, Block: BlockT> State<B, E, Block> {
 }
 
 impl<B, E, Block> State<B, E, Block> where
-	Block: BlockT + 'static,
-	B: client::backend::Backend<Block, KeccakHasher, RlpCodec> + Send + Sync + 'static,
-	E: CallExecutor<Block, KeccakHasher, RlpCodec> + Send + Sync + 'static,
+	Block: BlockT,
+	B: client::backend::Backend<Block, KeccakHasher, RlpCodec>,
+	E: CallExecutor<Block, KeccakHasher, RlpCodec>,
 {
 	fn unwrap_or_best(&self, hash: Trailing<Block::Hash>) -> Result<Block::Hash> {
-		Ok(match hash.into() {
-			None => self.client.info()?.chain.best_hash,
-			Some(hash) => hash,
-		})
+		::helpers::unwrap_or_else(|| Ok(self.client.info()?.chain.best_hash), hash)
 	}
 }