token

Tạo và quản lý token có thể thay thế trên Convex. Sử dụng khi người dùng muốn tạo token mới, kiểm tra số dư token, hoặc quản lý nguồn cung token.

npx skills add https://github.com/convex-dev/convex --skill token

Fungible Tokens on Convex

Fungible tokens use the @convex.fungible standard library (convex-core/src/main/cvx/convex/asset/fungible.cvx). See the convex-lisp skill for CVM conventions, and transact for how transactions are signed.

Create a New Token

Fixed supply — no further tokens can ever be minted:

(deploy (@convex.fungible/build-token {:supply 1000000}))

Mintable — build-token alone provides no mint or burn capability. To allow minting you must compose add-mint into the same deployment:

(deploy [(@convex.fungible/build-token {:supply 1000000})
         (@convex.fungible/add-mint {:minter *address* :max-supply 1000000000})])

Decide which the user wants before deploying — the choice is permanent, and a token deployed without add-mint fails on any later mint attempt.

build-token config: :supply (defaults to 0), :initial-holder (defaults to *address*), :decimals. add-mint config: :minter (any trust monitor, defaults to *address*) and :max-supply (from protocol v1, defaults to unlimited).

Always set :max-supply explicitly. Before v1 activates, omitting it defaults the cap to 0 — and because 0 is truthy in CVM, that installs a zero cap which blocks all minting, silently producing a mintable-looking token that can never mint (#528). Setting it explicitly is correct under both genesis and v1. See the protocol-versions skill.

deploy returns the token's actor address.

Operations

TaskSource
Check balance(@convex.fungible/balance #TOKEN #HOLDER)
Total supply(@convex.fungible/total-supply #TOKEN)
Decimals(@convex.fungible/decimals #TOKEN)
Transfer(@convex.fungible/transfer #TOKEN #DEST AMOUNT)
Mint(@convex.fungible/mint #TOKEN AMOUNT)
Burn(@convex.fungible/burn #TOKEN AMOUNT)

There is no quantity function — it returns :UNDECLARED. Total supply is total-supply.

balance, total-supply and decimals are reads: use a query, not a transaction. transfer, mint and burn change state and must be transactions.

If a Convex MCP server is configured, its getBalance and transfer tools also accept a token parameter.

Authorisation

Minting requires the caller to satisfy the token's :minter trust monitor; anything else fails with :TRUST. :minter takes any trust monitor, not just an address — see the trust skill for composing them (a mint window, a multi-party whitelist, delegated revocation). Creating, transferring, minting and burning are all transactions, so they need a key the user has supplied — see the transact skill. Without one you can prepare the source but not execute it.

Thêm skills từ convex-dev

convex-lisp
convex-dev
Tài liệu tham khảo ngôn ngữ Convex Lisp — quy ước CVM, gọi mã thư viện, định nghĩa actor, mã juice và lỗi. Sử dụng khi viết hoặc gỡ lỗi mã nguồn CVM cho…
ecosystem
convex-dev
Định hướng trong hệ sinh thái Convex — thứ gì nằm trong repository nào, specs và docs ở đâu, và những thư viện client nào tồn tại. Sử dụng khi bạn cần ngữ cảnh…
local-network
convex-dev
Chạy mạng thử nghiệm Convex cục bộ để phát triển. Sử dụng khi kiểm tra các thay đổi với mạng trực tiếp, tái hiện sự cố của đồng nghiệp, hoặc khi không có mạng từ xa…
protocol-versions
convex-dev
Các phiên bản giao thức, di chuyển và nâng cấp v1 — nên viết theo ngữ nghĩa nào, và cách thay đổi hành vi CVM mà không fork mạng. Sử dụng khi…
etch
convex-dev
Kiểm tra và bảo trì một cửa hàng Etch — cơ sở dữ liệu định địa chỉ theo nội dung của Convex. Sử dụng khi kiểm tra bộ nhớ ngang hàng, chẩn đoán hỏng hóc, thu gom rác, hoặc…
juice
convex-dev
Hạch toán Juice — chi phí tính toán và băng thông trên CVM. Sử dụng khi phân tích chi phí thực thi giao dịch, chẩn đoán lỗi :JUICE, hoặc…
trust
convex-dev
Trust monitors — mô hình ủy quyền trên chuỗi có thể kết hợp của Convex. Sử dụng khi viết kiểm soát truy cập, hạn chế chức năng của tác nhân, xác định ai có thể mint hoặc…
memory
convex-dev
Kế toán và hạn mức bộ nhớ — chi phí lưu trữ trên chuỗi, và cách giảm thiểu cũng như thu hồi nó. Sử dụng khi suy luận về sự tăng trưởng trạng thái, chẩn đoán một…