@@ -103,12 +103,10 @@ If you chose to download the ICRC-1 ledger files with the script, you need to re
103
103
dfx start --background --clean
104
104
```
105
105
106
- ### Step 5: Create a new identity that will work as a minting account:
106
+ ### Step 5: Use the anonymous identity as the minting account:
107
107
108
108
``` bash
109
- dfx identity new minter --storage-mode plaintext
110
- dfx identity use minter
111
- export MINTER=$( dfx identity get-principal)
109
+ export MINTER=$( dfx --identity anonymous identity get-principal)
112
110
```
113
111
114
112
::: info
@@ -117,18 +115,17 @@ Transfers from the minting account will create Mint transactions. Transfers to t
117
115
118
116
:::
119
117
120
- ### Step 6: Switch back to your default identity and record its principal to mint an initial balance to when deploying the ledger:
118
+ ### Step 6: Record your default identity's principal to mint an initial balance to when deploying the ledger:
121
119
122
120
``` bash
123
- dfx identity use default
124
121
export DEFAULT=$( dfx identity get-principal)
125
122
```
126
123
127
124
### Step 7: Deploy the ICRC-1 ledger locally:
128
125
129
126
Take a moment to read the details of the call made below. Not only are you deploying an ICRC-1 ledger canister, you are also:
130
127
131
- - Setting the minting account to the principal you saved in a previous step (` MINTER ` )
128
+ - Setting the minting account to the anonymous principal you saved in a previous step (` MINTER ` )
132
129
- Minting 100 tokens to the DEFAULT principal
133
130
- Setting the transfer fee to 0.0001 tokens
134
131
- Naming the token Local ICRC1 / L-ICRC1
@@ -189,23 +186,16 @@ Replace the contents of the `src/token_transfer_backend/main.mo` file with the f
189
186
import Icrc1Ledger " canister:icrc1_ledger_canister" ;
190
187
import Debug " mo:base/Debug" ;
191
188
import Result " mo:base/Result" ;
192
- import Option " mo:base/Option" ;
193
- import Blob " mo:base/Blob" ;
194
189
import Error " mo:base/Error" ;
195
190
196
191
actor {
197
192
198
- type Account = {
199
- owner : Principal;
200
- subaccount : ? [Nat8];
201
- };
202
-
203
193
type TransferArgs = {
204
194
amount : Nat;
205
- toAccount : Account;
195
+ toAccount : Icrc1Ledger. Account;
206
196
};
207
197
208
- public shared ({ caller }) func transfer(args : TransferArgs) : async Result.Result< Icrc1Ledger.BlockIndex, Text> {
198
+ public shared func transfer(args : TransferArgs) : async Result.Result< Icrc1Ledger.BlockIndex, Text> {
209
199
Debug.print(
210
200
" Transferring "
211
201
# debug_show (args.amount)
@@ -222,7 +212,7 @@ actor {
222
212
from_subaccount = null;
223
213
// if not specified, the default fee for the canister is used
224
214
fee = null;
225
- // we take the principal and subaccount from the arguments and convert them into an account identifier
215
+ // the account we want to transfer tokens to
226
216
to = args.toAccount;
227
217
// a timestamp indicating when the transaction was created by the caller ; if it is not specified by the caller then this is set to the current ICP time
228
218
created_at_time = null;
0 commit comments