Hello Substrate and Polkadot community,
I am working on creating a decentralized exchange (DEX) using Substrate pallets and I've encountered an issue related to transferring tokens from the contract owner to the pallet address.
To add liquidity for a token pair (e.g., XXX/USDT) in my DEX, users need to provide the contract address of the token (e.g., XXX). Before initiating the transfer, I want to ensure that the user is indeed the owner of the contract. Once the ownership is verified, I need to transfer tokens from the contract address (e.g., 5xsdf6s5d4f6sd4f65sd4fs65df46s5d4f6s5d4f
) to the pallet address.
Could anyone provide guidance or sample code on how to achieve this token transfer from the contract owner to the pallet address while ensuring the user is the actual owner of the contract?
Any help or suggestions would be greatly appreciated. Thank you!
Update
I want to transfer token with this code:
#[pallet::call_index(9)]
#[pallet::weight(10_000)]
pub fn total_supply(
origin: OriginFor<T>,
token: T::AccountId,
currency: T::AccountId,
currency_amount: BalanceOf<T>,
token_amount: BalanceOf<T>,
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
T::Currency::transfer(&who, &T::PalletId::get().into_account(),
T::MinDeposit::get(), ExistenceRequirement::KeepAlive)?;
}
but in this code transfer native token of the chain and I need to transfer from XXX
token to the pallet account.