blockchain - Dynamic Token In A Module | Aptos MOVE - Stack Overflow
I'm new to Aptos Move,
I'm writing a module to allow dynamic token as Solidity. In Solidity, we can pass the ERC20 address into the constructor, the smart contract will parse this address to an ERC20 smart contract and call transferFrom
function to transfer an amount
of token from sender
to this smart contract.
With a different architecture, according to my current knowledge, when constructing a module in Aptos Move, the owner still has to declare the type of token by function_name<address:token's module>(parameters)
. But the users calling functions related to the token have to include this function_name<address:token's module>(parameters)
too.
Summary: I'm wondering that in Solidity, users don't have to care too much about the blockchain, such as the address of the token, I just know that they have an amount of this token, so they can call some functions. However, in Aptos, users have to clearly declare what token they want to use.
Is the way I mention in Aptos Move when transferring tokens a standard and common way? Or did I misunderstand any part?
Thanks in advance for your guidance!
I'm new to Aptos Move,
I'm writing a module to allow dynamic token as Solidity. In Solidity, we can pass the ERC20 address into the constructor, the smart contract will parse this address to an ERC20 smart contract and call transferFrom
function to transfer an amount
of token from sender
to this smart contract.
With a different architecture, according to my current knowledge, when constructing a module in Aptos Move, the owner still has to declare the type of token by function_name<address:token's module>(parameters)
. But the users calling functions related to the token have to include this function_name<address:token's module>(parameters)
too.
Summary: I'm wondering that in Solidity, users don't have to care too much about the blockchain, such as the address of the token, I just know that they have an amount of this token, so they can call some functions. However, in Aptos, users have to clearly declare what token they want to use.
Is the way I mention in Aptos Move when transferring tokens a standard and common way? Or did I misunderstand any part?
Thanks in advance for your guidance!
Share Improve this question asked Nov 16, 2024 at 1:55 GavinGavin 576 bronze badges1 Answer
Reset to default 0Yeah, that's correct. The approach in Aptos Move is intentionally more explicit than Solidity. When transferring tokens in Aptos Move, you need to specify the token type using generics like:
public entry fun deposit<CoinType>(amount: u64) {
// Transfer logic here
}`
This explicit type declaration is a core design choice in Move that provides additional safety and clarity. Solidity uses dynamic dispatch through addresses, but Move uses static typing to prevent runtime errors and make token interactions more predictable.
Users calling your module will indeed need to specify the token type:
module.deposit<0x1::aptos_coin::AptosCoin>(100)
This is the standard pattern across Aptos ecosystem and brings benefits like compile-time type checking and clearer code intentions. Hope it will be a clear understanding for you
- Windows 10硬件产品发布会汇总 微软喊你换电脑
- Windows8是备胎?解析微软移动市场战略
- Why does this typecheck in Lean? - Stack Overflow
- java - Difficulty Embedding ICC Profile into PDF Using PDFBox, iText, and Ghostscrip - Stack Overflow
- amazon ec2 - Flask Babel inconsistent language switching in production - Stack Overflow
- Python Selenium Error - Sandbox cannot access executable - Stack Overflow
- apache spark - Can't save pyspark ML model :py4j.protocol.Py4JJavaError: An error occurred while calling o577.save. : ja
- flutter - having issue about qr code scanner that can scan almost everything - Stack Overflow
- swift - How to Add .mlmodel File to Xcode App Playgrounds (.swiftpm) Project? - Stack Overflow
- Django is not updating on MacOS - Stack Overflow
- verilog - Is it possible to create task within interface for specific modport? - Stack Overflow
- macos - Restriction of media fetched with API in browser in iOS and Mac systems - Stack Overflow
- c# - IdentityServer4 and returning an error in response - Stack Overflow
- python - Multi-level list with each level number included - Stack Overflow
- connecting Shopify to external Stripe checkout script - Stack Overflow
- vba - Excel Macro to rename tabs is failing on the second run - Stack Overflow
- python - Change one pair of vertices to create a cycle in an oriented graph - Stack Overflow