admin管理员组文章数量:1435859
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
本文标签: blockchainDynamic Token In A ModuleAptos MOVEStack Overflow
版权声明:本文标题:blockchain - Dynamic Token In A Module | Aptos MOVE - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745668595a2669431.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论