Closed4

Substrate で Asset を発行する

かんなかんな

Substrate に Asset pallet を追加して、独自アセットを発行してみたい。
https://substrate.dev/docs/en/tutorials/add-contracts-pallet

git clone -b v3.0.0 --depth 1 https://github.com/substrate-developer-hub/substrate-node-template
cd substrate-node-template
cargo build --release

git clone -b v3.0.0 --depth 1 https://github.com/substrate-developer-hub/substrate-front-end-template
cd substrate-front-end-template
yarn install
かんなかんな

runtime/Cargo.toml
[dependencies] に pallet-assets を指定
[feature] std に pallet-assets/std を追加

かんなかんな

pallet の Config を設定する

https://substrate.dev/rustdocs/v3.0.0/pallet_assets/pallet/trait.Config.html

parameter_types! {
	pub const StringLimit: u32 = 100;
	pub const AssetDepositBase: u32 = 500;
	pub const AssetDepositPerZombie: u32 = 500;
	pub const MetadataDepositBase: u32 = 500;
	pub const MetadataDepositPerByte: u32 = 500;
}

impl pallet_assets::Config for Runtime {
	type Event = Event;
	type Balance = u32;
	type AssetId = u64;
	type Currency = pallet_balances::Module<Runtime>;
	type ForceOrigin = frame_system::EnsureRoot<AccountId>;
	type AssetDepositBase = AssetDepositBase;
	type AssetDepositPerZombie = AssetDepositPerZombie;
	type StringLimit = StringLimit;
	type MetadataDepositBase = MetadataDepositBase;
	type MetadataDepositPerByte = MetadataDepositPerByte;
	type WeightInfo = ();
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
	pub enum Runtime where
		Block = Block,
		NodeBlock = opaque::Block,
		UncheckedExtrinsic = UncheckedExtrinsic
	{
		System: frame_system::{Module, Call, Config, Storage, Event<T>},
		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
		Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
		Aura: pallet_aura::{Module, Config<T>},
		Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
		Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
		TransactionPayment: pallet_transaction_payment::{Module, Storage},
		Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
		// Include the custom logic from the template pallet in the runtime.
		TemplateModule: pallet_template::{Module, Call, Storage, Event<T>},
		Assets: pallet_assets::{Event<T>} // 追加した
	}
);

これでビルドは通った。

かんなかんな


asset pallet のメニューが表示されたが、、、 asset を発行はできない。
理解しないで設定しているから全然だめ。。。

このスクラップは2022/05/15にクローズされました