1

I have configured an asset in the GenesisConfig of my node's chain_spec as following:

        assets: AssetsConfig {
            assets: vec![(1000, root_key.clone(), true, 1)], // Genesis assets: id, owner, is_sufficient, min_balance
            metadata: vec![(1000, "Asset name".into(), "ASSET_NAME".into(), 0)], // Genesis metadata: id, name, symbol, decimals
            accounts: vec![], // Genesis accounts: id, account_id, balance
        },

I would like to mint this asset using pallet-assets and I am doing this:

<pallet_assets::Pallet<T> as Mutate<T::AccountId>>::mint_into(
          T::MyAssetId::get(),
          &accountId,
          amount)?;

but I get error

    Token(
        UnknownAsset,
    ),

How can I mint assets configured in the GenesisConfig? I was convinced that I did not need to create it first.

1 Answer 1

3

After looking how PolkadotJS app was managing to mint the asset, I figured that I was trying to call the wrong function. I actually do need to call

#[pallet::weight(T::WeightInfo::mint())]
        pub fn mint(
            origin: OriginFor<T>,
            #[pallet::compact] id: T::AssetId,
            beneficiary: AccountIdLookupOf<T>,
            #[pallet::compact] amount: T::Balance,
        ) -> DispatchResult {

which inside calls do_mint which eventually does the check that I was expecting (i.e. check if the asset already exists - created from GenesisConfig)

Asset::<T, I>::get(id)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.