-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
;; Asset demo | ||
|
||
(import convex.asset :as asset) | ||
(import convex.fungible :as fungible) | ||
(import convex.fungible :as fun) | ||
(import asset.box :as box) | ||
(import asset.multi-token :as mt) | ||
|
||
;; =============================================== | ||
;; Creating a token: smart contract style | ||
(def MYCOIN | ||
(deploy | ||
[(fun/build-token {:supply 1000}) | ||
(fun/add-mint {:minter *address*} )] )) | ||
|
||
(asset/balance MYCOIN) | ||
(asset/mint MYCOIN 100) | ||
(asset/balance MYCOIN) | ||
|
||
(asset/transfer #13 [MYCOIN 100]) | ||
|
||
|
||
;; ============================================== | ||
;; Creating a token: factory actor style | ||
|
||
;; create the token | ||
(call mt (create :FOO)) | ||
|
||
;; Give it a name for convenience | ||
(def TOK [mt :FOO]) | ||
|
||
(asset/balance TOK) | ||
|
||
;; create some coins) | ||
(asset/mint TOK 1000) | ||
|
||
(asset/balance TOK) | ||
|
||
(asset/transfer #13 [TOK 150]) | ||
|
||
;; =========================================== | ||
;; An interesting implementation note | ||
|
||
*holdings* | ||
|
||
;; =========================================== | ||
;; Now for NFTs | ||
|
||
(import asset.nft.basic :as nft) | ||
|
||
(def NFT-ID (call nft (create {:url "https://mikera.net/art/img1.jpg" :author "Mike"}))) | ||
|
||
(call nft (get-metadata NFT-ID)) | ||
|
||
(asset/balance nft) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,4 @@ | |
;; ================================= | ||
;; Boxing | ||
|
||
() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters