Random Hash logic return 0x0000000000000000000000000000

I try to follow this guide for Substrate Blockchain in Rustlang: https://shawntabrizi.github.io/substrate-collectables-workshop/#/2/generating-random-data

Once I updated my .rs file with the random_hash variable and create a new Kitty ,all values in the Kitty property has the value “kittyStorage.kitties: Kitty

Appreciate any input on why this happens. I paste my code below:

use support::{decl_storage, decl_module, StorageValue, StorageMap, dispatch::Result, ensure, decl_event};
use system::ensure_signed;
use runtime_primitives::traits::{As, Hash};
use parity_codec::{Encode, Decode};

#[derive(Encode, Decode, Default, Clone, PartialEq)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct Kitty<Hash, Balance> {
    unique_id: Hash,
    dna: Hash,
    price: Balance,
    gen: u64,

//pub trait Trait: system::Trait {}
pub trait Trait: balances::Trait {
    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;

    pub enum Event<T>
    <T as system::Trait>::AccountId,
    <T as system::Trait>::Hash {
        Created(AccountId, Hash),

decl_storage! {
    trait Store for Module<T: Trait> as KittyStorage {
        OwnedKitty get(kitty_of_owner): map T::AccountId => T::Hash;
        Kitties get(kitty): map T::Hash => Kitty<T::Hash, T::Balance>;
        KittyOwner get(owner_of): map T::Hash => Option<T::AccountId>;

        Nonce: u64;

decl_module! {
    pub struct Module<T: Trait> for enum Call where origin: T::Origin {

        fn deposit_event<T>() = default;

        fn create_kitty(origin) -> Result {
            let sender = ensure_signed(origin)?;
            let nonce = <Nonce<T>>::get();

            let random_hash = (<system::Module<T>>::random_seed(), &sender, nonce).using_encoded(<T as system::Trait>::Hashing::hash);

            ensure!(!<KittyOwner<T>>::exists(random_hash), "Kitty already exists");

            let new_kitty = Kitty {
                unique_id: random_hash,
                dna: random_hash,
                price: <T::Balance as As<u64>>::sa(0),
                gen: 0,

            <Kitties<T>>::insert(random_hash, new_kitty);
            <KittyOwner<T>>::insert(random_hash, &sender);
            <OwnedKitty<T>>::insert(&sender, random_hash);

            <Nonce<T>>::mutate(|n| *n += 1);

            Self::deposit_event(RawEvent::Created(sender, random_hash));


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.