deploy

Triển khai một actor (hợp đồng thông minh) lên mạng Convex. Sử dụng khi người dùng muốn tạo một actor mới trên chuỗi với các hàm đã được xuất.

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

Deploy a Convex Actor

Actors are autonomous on-chain programs with their own address, state, and callable functions.

See the convex-lisp skill for CVM conventions and error codes. Deploying is a transaction, so it needs a key the user has supplied — see transact.

Actor Structure

A typical actor deployment:

(deploy
  '(do
     ;; Internal state (private to the actor)
     (def counter 0)

     ;; Callable functions: mark each with ^:callable so it can be
     ;; invoked from outside the actor via (call ...)
     (defn ^:callable increment []
       (set! counter (+ counter 1))
       counter)

     (defn ^:callable get-count []
       counter)))

Key Rules

  • deploy returns the new actor's address (e.g. #12345)
  • Only functions tagged with ^:callable metadata can be called from outside (there is no export form). The equivalent map form is ^{:callable true}
  • Use set! to update an existing def from inside a function; plain defs declared in the actor body are private state
  • Actors have their own *address* and *balance*
  • Use (set-controller #ADDR) inside the actor to set who can upgrade it
  • deploy also accepts a vector of code forms, which is how library builders are composed into one actor: (deploy [(@convex.fungible/build-token {…}) (@convex.fungible/add-mint {…})])

After Deployment

  1. Note the returned address for the user
  2. Optionally register a CNS name: (*registry*/create 'my.actor.name #NEW-ADDR) — needs control of the parent namespace; see the cns skill
  3. Test by calling a ^:callable function: (call #NEW-ADDR (get-count))

Workflow

  1. Help the user design the actor based on $ARGUMENTS
  2. Write the Convex Lisp source
  3. Deploy using transact with the (deploy ...) expression
  4. Verify the deployment with a test query

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…