From 5a5212169b26d97980e65617cdd21d5239f1d095 Mon Sep 17 00:00:00 2001 From: Jude Nelson Date: Tue, 20 Apr 2021 14:07:34 -0400 Subject: [PATCH] new sample contracts that use the native fungible token type (for testing asset movement in clarity-cli) --- sample-contracts/tokens-ft-mint.clar | 5 +++++ sample-contracts/tokens-ft.clar | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 sample-contracts/tokens-ft-mint.clar create mode 100644 sample-contracts/tokens-ft.clar diff --git a/sample-contracts/tokens-ft-mint.clar b/sample-contracts/tokens-ft-mint.clar new file mode 100644 index 000000000..6477f3f5d --- /dev/null +++ b/sample-contracts/tokens-ft-mint.clar @@ -0,0 +1,5 @@ +(begin + (as-contract + (contract-call? 'S1G2081040G2081040G2081040G208105NK8PE5.tokens mint! u100) + ) +) \ No newline at end of file diff --git a/sample-contracts/tokens-ft.clar b/sample-contracts/tokens-ft.clar new file mode 100644 index 000000000..140d3e7ee --- /dev/null +++ b/sample-contracts/tokens-ft.clar @@ -0,0 +1,16 @@ +(define-fungible-token tokens) +(define-private (get-balance (account principal)) + (ft-get-balance tokens account)) + +(define-private (token-credit! (account principal) (amount uint)) + (ft-mint? tokens amount account)) + +(define-public (token-transfer (to principal) (amount uint)) + (ft-transfer? tokens amount tx-sender to)) + +(define-public (mint! (amount uint)) + (token-credit! tx-sender amount)) + +(token-credit! tx-sender u10300) +(token-transfer 'SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR u10000) +(token-transfer 'SM2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQVX8X0G u300)