2

I am working on a decentralized exchange (DEX) using the Substrate framework, and I need help with transferring non-native tokens between user accounts within the DEX.

Suppose a user creates a token with smart contract for exmaple named ZZZ on my chain. My goal is to facilitate transfers of this token between users within the DEX.

Can someone please provide an example or guidance on implementing non-native token transfers between user accounts in a Substrate-based DEX ? Any relevant resources or suggestions would be greatly appreciated.

1 Answer 1

1

If I were you I'd start looking into how a smart contract DEX works. E.g. uniswap v1 is the most straightforward. Try to understand how the DEX smart contracts interact with the token contract (e.g. ERC20).

Then, because you want a "Substrate-based DEX" interacting with these token contracts, start looking into chain extensions. With chain extensions you can expose parts of your runtime logic to smart contracts. This is the hardest part because in stead of having solely smart contracts interacting with each other, you have extrinsics interacting with smart contracts (and vice versa).

But a simple answer to your question is that it will come down to transfering tokens from the user to the liq pool in exchange for the other token. This fn transfer message will probably be called within an extrinsic (because you want a substrate-based DEX).

2
  • in my senario user want to create token with own smart contract .
    – Mr Coder
    Apr 19, 2023 at 18:24
  • I edited the answer Apr 20, 2023 at 7:33

Your Answer

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

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