Skip to content

Commit 22c5b2b

Browse files
committed
README
1 parent 1921bd8 commit 22c5b2b

File tree

1 file changed

+47
-26
lines changed

1 file changed

+47
-26
lines changed

motoko/ic-pos/README.md

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ keywords: [advanced, motoko, bitcoin, pos, point of sale, ckbtc]
44

55
# IC-POS
66

7-
[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/ic-pos)
8-
97
![](./media/header.png)
108

119

@@ -27,9 +25,9 @@ For deeper understanding of the ICP < > BTC integration, see the IC wiki article
2725

2826
IC-POS is deployed on the Internet Computer. You can try it out here:
2927

30-
https://hngac-6aaaa-aaaal-qb6tq-cai.icp0.io/
28+
https://hngac-6aaaa-aaaal-qb6tq-cai.icp0.io
3129

32-
https://github.com/kristoferlund/ic-pos/assets/9698363/f67d9952-3ee1-4876-a5e5-6ed0e29bae9d
30+
**Note:** The live version of IC-POS uses real ckBTC tokens. To test, use only fractions of a token to avoid losing funds.
3331

3432
## Architecture
3533

@@ -56,39 +54,57 @@ The frontend interacts with the following IC canisters:
5654
- `ckbtc index` - to fetch transaction history.
5755
- `internet identity` - to authenticate users.
5856

59-
# Local deployment
57+
## Setup, dev environment
58+
59+
Pre-requisites:
60+
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+
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.
6068

61-
## Prerequisites
69+
```bash
70+
bash ./scripts/deploy.sh
71+
```
6272

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`
73+
Once the script has finished, you should proceed to step 10 to create a store and mint yourself some test tokens.
6674

67-
### Step 1: Start a local instance of the replica:
75+
## Deploy manually
6876

69-
(To complete steps 1-7 in one go, you can run the `./scripts/deploy.sh` script.)
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:
7086

7187
```bash
7288
dfx start --clean --background
7389
```
7490

75-
### Step 2: Deploy the Internet Identity canister:
91+
### 3. Deploy the Internet Identity canister:
7692

7793
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.
7894

7995
```bash
8096
dfx deploy internet_identity
8197
```
8298

83-
### Step 3: Save the current principal as a variable:
99+
### 4. Save the current principal as a variable:
84100

85101
The principal will be used when deploying the ledger canister.
86102

87103
```bash
88104
export OWNER=$(dfx identity get-principal)
89105
```
90106

91-
### Step 3: Deploy the ckBTC ledger canister:
107+
### 5. Deploy the ckBTC ledger canister:
92108

93109
The responsibilities of the ledger canister is to keep track of token balances and handle token transfers.
94110

@@ -131,7 +147,7 @@ dfx deploy icrc1_ledger --argument '
131147
'
132148
```
133149

134-
### Step 4: Deploy the index canister:
150+
### 6. Deploy the index canister
135151

136152
The index canister syncs the ledger transactions and indexes them by account.
137153

@@ -143,7 +159,7 @@ dfx deploy icrc1_index --argument '
143159
'
144160
```
145161

146-
### Step 5: Deploy the icpos canister:
162+
### 7. Deploy the icpos canister
147163

148164
The icpos canister manages the store configuration and sends notifications when a payment is received.
149165

@@ -153,31 +169,36 @@ The `--argument '(0)'` argument is used to initialize the canister with `startBl
153169
dfx deploy icpos --argument '(0)'
154170
```
155171

156-
### Step 6: Configure the icpos canister:
172+
### 8. Configure the icpos canister
157173

158-
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:
159175

160176
```bash
161177
dfx canister call icpos setCourierApiKey "pk_prod_..."
162178
```
163179

164-
### Step 7: Build and run the frontend:
180+
### 9. Build and run the frontend
165181

166-
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.
167183

168184
```bash
169185
pnpm install
170-
dfx deploy icpos_frontend
186+
pnpm run dev
171187
```
172-
### Step 8: Make a transfer!
188+
189+
The app should now be accessible at a local url, typically `http://localhost:5173`.
190+
191+
### 10. Make a transfer!
192+
193+
173194

174195
Now that everything is up and running, you can make a transfer to your newly created store.
175196

176197
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.
177198

178-
#### 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
179200

180-
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.
181202

182203
```bash
183204
dfx canister call icrc1_ledger icrc1_transfer '
@@ -190,9 +211,9 @@ dfx canister call icrc1_ledger icrc1_transfer '
190211
'
191212
```
192213

193-
#### 8.2: Create the second store:
214+
#### 10.2 Create the second store
194215

195-
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.
196217

197218
Now, go back to the first browser/store, navigate to the `Send` page, and transfer some tokens to the second store.
198219

0 commit comments

Comments
 (0)