You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Note:** The live version of IC-POS uses real ckBTC tokens. To test, use only fractions of a token to avoid losing funds.
33
31
34
32
## Architecture
35
33
36
34
### Backend
37
35
38
-
The backend is written in Motoko and consists of one canister, `icpos`. It exposes four public methods:
36
+
The backend is written in Motoko and consists of one canister, `icpos`. It exposes five public methods:
39
37
40
38
-`getMerchant` - returns the store configuration for a given principal.
41
39
-`updateMerchant` - updates the store configuration for a given principal.
42
40
-`setCourierApiKey` - sets the Courier API key used to send email and SMS notifications. Only the canister controller can call this method.
43
-
-`setLedgerId` - sets the ledger ID to monitor for transactions. Only the canister controller can call this method.
41
+
-`setLedgerId` - xsets the ledger ID to monitor for transactions. Only the canister controller can call this method.
44
42
-`getLogs` - The canister maintains a debug log that can be fetched using this method.
45
43
46
44
In addition to the public methods, the canister uses a [timer](https://internetcomputer.org/docs/current/motoko/main/timers/) to monitor ledger transactions. When a new transaction is found that matches a configured store – depending on the store settings – the canister will send a notification either by email or SMS.
@@ -56,37 +54,57 @@ The frontend interacts with the following IC canisters:
56
54
-`ckbtc index` - to fetch transaction history.
57
55
-`internet identity` - to authenticate users.
58
56
59
-
#Local deployment
57
+
## Setup, dev environment
60
58
61
-
## Prerequisites
59
+
Pre-requisites:
62
60
63
-
-[x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
64
-
-[x] Install [Node.js](https://nodejs.org/en/).
65
-
-[x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`
61
+
-[Local Internet Computer dev environment](https://internetcomputer.org/docs/current/developer-docs/backend/rust/dev-env)
62
+
-[Node 20+](https://nodejs.org/en/)
63
+
-[pnpm](https://pnpm.io/installation)
64
+
65
+
## Deploy using script
66
66
67
-
### Step 1: Start a local instance of the replica:
67
+
To get started quickly and deploy the IC-POS app locally, you can run a deploy script. This script will start a local replica, deploy the necessary canisters, and build and deploy the frontend.
68
+
69
+
```bash
70
+
bash ./scripts/deploy.sh
71
+
```
72
+
73
+
Once the script has finished, you should proceed to step 10 to create a store and mint yourself some test tokens.
74
+
75
+
## Deploy manually
76
+
77
+
### 1. Clone the examples repository and navigate to the IC-POS project:
78
+
79
+
```bash
80
+
git clone https://github.com/dfinity/examples
81
+
cd examples/motoko/ic-pos
82
+
```
83
+
84
+
85
+
### 2. Start a local instance of the replica:
68
86
69
87
```bash
70
88
dfx start --clean --background
71
89
```
72
90
73
-
### Step 2: Deploy the Internet Identity canister:
91
+
### 3. Deploy the Internet Identity canister:
74
92
75
93
Integration with the [Internet Identity](https://internetcomputer.org/internet-identity/) allows store owners to securely setup and manage their store. The Internet Identity canister is already deployed on the IC mainnet. For local development, you need to deploy it to your local instance of the IC.
76
94
77
95
```bash
78
-
dfx deploy --network localinternet_identity
96
+
dfx deploy internet_identity
79
97
```
80
98
81
-
### Step 3: Save the current principal as a variable:
99
+
### 4. Save the current principal as a variable:
82
100
83
101
The principal will be used when deploying the ledger canister.
84
102
85
103
```bash
86
104
export OWNER=$(dfx identity get-principal)
87
105
```
88
106
89
-
### Step 3: Deploy the ckBTC ledger canister:
107
+
### 5. Deploy the ckBTC ledger canister:
90
108
91
109
The responsibilities of the ledger canister is to keep track of token balances and handle token transfers.
92
110
@@ -101,7 +119,7 @@ Take a moment to read the details of the call we are making below. Not only are
101
119
- Setting the transfer fee to 10 LCKBTC.
102
120
103
121
```bash
104
-
dfx deploy --network local --specified-id mxzaz-hqaaa-aaaar-qaada-cai icrc1_ledger --argument '
The icpos canister manages the store configuration and sends notifications when a payment is received.
147
165
148
166
The `--argument '(0)'` argument is used to initialize the canister with `startBlock` set to 0. This is used to tell the canister to start monitoring the ledger from block 0. When deploying to the IC mainnet, this should be set to the current block height to prevent the canister from processing old transactions.
149
167
150
168
```bash
151
-
dfx deploy --network localicpos --argument '(0)'
169
+
dfx deploy icpos --argument '(0)'
152
170
```
153
171
154
-
### Step 6: Configure the icpos canister:
172
+
### 8. Configure the icpos canister
155
173
156
-
ic-pos uses [Courier](https://courier.com/) to send email and SMS notifications. If you want to enable notifications, you need to sign up for a Courier account and and create and API key. Then issue the following command:
174
+
IC-POS uses [Courier](https://courier.com/) to send email and SMS notifications. If you want to enable notifications, you need to sign up for a Courier account and and create and API key. Then issue the following command:
Run npm to install dependencies and start the frontend. The frontend will be available at http://localhost:5173.
182
+
Run npm to install dependencies and start a development version of the frontend.
165
183
166
184
```bash
167
-
npm install
168
-
npm run dev
185
+
pnpm install
186
+
pnpm run dev
169
187
```
170
188
171
-
Why don't we deploy the frontend as a local canister? Vite uses lazy loading of modules. This does not work when deploying to a local canister. When deploying to the IC mainnet, this is not an issue. Also, running using `npm run dev` allows for hot reloading of the frontend code when making changes.
189
+
The app should now be accessible at a local url, typically `http://localhost:5173`.
172
190
173
-
### Step 8: Make a transfer!
191
+
### 10. Make a transfer!
174
192
175
-
Now that everything is up and running, you can make a transfer to your newly created store.
176
193
177
-
Transfers made from the owner principal will not trigger notifications in the UI since they are regarded as `mint` transactions. To test notifications, you need to make a transfer from another principal.
194
+
195
+
Now that everything is up and running, you can make a transfer to your newly created store.
178
196
179
197
The easiest way to do this is to create two stores using two different Internet Identity accounts, using two different web browsers. Then, transfer some tokens from one store to the other.
180
198
181
-
#### 8.1: Create the first store and supply it with some tokens:
199
+
#### 10.1 Create the first store and supply it with some tokens
182
200
183
-
Log in to the frontend using the Internet Identity. Configure the store and navigate to the `Receive`page. Click on the principal pill to copy the address to your clipboard. Then, using the `dfx` command, mint some tokens from your owner principal to the store principal.
201
+
Log in to the frontend using the Internet Identity. Configure the store with a name and then, on the main store page, click on the principal pill to copy the address to your clipboard. Using the `dfx` command, now mint some tokens from your owner principal to the store principal.
Log in to the frontend using **a new Internet Identity on another web browser**. Configure the store and navigate to the `Receive` page. Click on the principal pill to copy the address to your clipboard.
216
+
Log in to the frontend using **a new Internet Identity using another web browser**. Give this store a name as well and copy the store principal like in the previous step.
199
217
200
218
Now, go back to the first browser/store, navigate to the `Send` page, and transfer some tokens to the second store.
201
219
@@ -205,14 +223,11 @@ If everything is working, you should see a notification in the second store.
205
223
206
224
## Possible improvements
207
225
208
-
- Login state is not persisted. Reloading the app will log the user out. This should be done using `localStorage` or `sessionStorage`.
209
-
- Show more information about transactions. A transaction detail page.
226
+
- Show more information about transactions.
227
+
- A transaction detail page.
228
+
- Pagination, currently only the first 5 transactions are shown.
210
229
- Show a confirmation dialog after the user clicks on the `Send` button.
211
230
212
-
## Known issues
213
-
214
-
-
215
-
216
231
## Contributing
217
232
218
233
Contributions are welcome! Please open an issue or submit a pull request.
0 commit comments