Skip to content

既然 deposit 存币就是一个方法,那我可以给自己存100w个币吗 #262

Answered by qiwihui
hi-chenerge asked this question in Q&A
Discussion options

You must be logged in to vote

deposit 的作用是把币存入一个账户,前提是要有对应币的实体(比如价值 10 的 APT 币)。move 的机制保证结构体 struct Coin<phantom CoinType> has store { value: u64} 只能在定义的包(coin包)中处理,所以你在自己写的包中调用 Coin<AptosCoin> { value: 100000} 这种是会报错的。而要创建币,只能调用 coin::mint 方法,这个方法是需要传入 MintCapability 能力的,这个能力在初始化 Aptos 这个币的时候应该是被aptos这个系统拿着了,所以你没法自己mint Aptos这个币。 你可以看看这个mint的代码 https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-framework/sources/coin.move#L476

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hi-chenerge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants