Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 65138de

Browse files
authored
Merge pull request #726 from ipfs/docs/interop-examples-edit
First pass looking at interop example tutorial
2 parents 951224a + 28356d5 commit 65138de

File tree

1 file changed

+77
-20
lines changed

1 file changed

+77
-20
lines changed

examples/transfer-files/README.md

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ TODO: Insert final screenshot here
5151

5252
## Step-by-step instructions
5353

54-
**Instructions:**
54+
Here's what we are going to be doing, today:
5555

5656
- 1. Set up, install a go-ipfs node in your machine
5757
- 2. Make your daemons listen on WebSockets
@@ -62,37 +62,85 @@ TODO: Insert final screenshot here
6262
- 7. Dial to a node using WebSockets (your Desktop ones)
6363
- 8. Transfer files between all of your nodes, have fun!
6464

65+
Let's go.
6566

66-
-------------------------
67-
> Steps need to be updated once the final thing is finished
67+
### 1. Set up
6868

69-
### Start a go-ipfs daemon
69+
You'll need to have an implementation of IPFS running on your machine. Currently, this means either go-ipfs or js-ipfs.
7070

71-
1. Install go-ipfs from master (TODO: link).
71+
Installing go-ipfs can be done by installing the binary [here](https://ipfs.io/ipns/dist.ipfs.io/#go-ipfs). Alternatively, you could follow the instructions in the README at [ipfs/go-ipfs](https://github.com/ipfs/go-ipfs).
7272

73-
2. Run `ipfs init`
73+
Installing js-ipfs requires you to have node and [npm](https://www.npmjs.com). Then, you simply run:
7474

75-
3. Edit your IPFS config file, located at `~/.ipfs/config`
75+
```sh
76+
> npm install --global ipfs
77+
...
78+
> jsipfs --help
79+
Commands:
80+
...
81+
```
82+
83+
This will alias `jsipfs` on your machine; this is to avoid issues with `go-ipfs` being called `ipfs`.
84+
85+
At this point, you have either js-ipfs or go-ipfs running. Now, initialize it:
86+
87+
```
88+
> ipfs init
89+
```
90+
91+
or
7692

77-
4. Add a Websocket listener address to `Addresses.Swarm`. It should look like this after editing:
7893
```
79-
"Addresses": {
80-
"API": "/ip4/127.0.0.1/tcp/5001",
81-
"Gateway": "/ip4/0.0.0.0/tcp/8080",
82-
"Swarm": [
83-
"/ip4/0.0.0.0/tcp/4001",
84-
"/ip4/0.0.0.0/tcp/9999/ws"
85-
]
86-
},
94+
> jsipfs init
8795
```
8896

89-
5. Start the go-ipfs daemon with:
97+
This will set up an `init` file in your home directory.
98+
99+
### 2. Make your daemons listen on WebSockets
100+
101+
At this point, you need to edit your `config` file, the one you just set up with `{js}ipfs init`. It should be in either `~/.jsipfs/config` or `~/.ipfs/config`, depending on whether you're using JS or Go. You can run `cat ~/.jsipfs/config` to see the contents of the JSON file.
102+
103+
Since websockets are currently not stable and are experimental, you'll need to add the ability for your daemon to listen on Websocket addresses. Look into your init file (using `cat`) and find the `Addresses` block:
104+
105+
```json
106+
"Addresses": {
107+
"Swarm": [
108+
"/ip4/0.0.0.0/tcp/4002"
109+
],
110+
"API": "/ip4/127.0.0.1/tcp/5002",
111+
"Gateway": "/ip4/127.0.0.1/tcp/9090"
112+
}
90113
```
91-
ipfs daemon
114+
115+
To make Websockets work, open up the `config` file and add the following entry to your `Swarm` array: `/ip4/0.0.0.0/tcp/9999/ws`. Now, it should look like this:
116+
117+
118+
```json
119+
"Addresses": {
120+
"Swarm": [
121+
"/ip4/0.0.0.0/tcp/4002",
122+
"/ip4/0.0.0.0/tcp/9999/ws"
123+
],
124+
"API": "/ip4/127.0.0.1/tcp/5002",
125+
"Gateway": "/ip4/127.0.0.1/tcp/9090"
126+
}
92127
```
93128

94-
6. You should see the Websocket address in the output:
129+
Now it should listen on Websockets. We're ready to...
130+
131+
### 3. Start the WebApp project
132+
133+
Ok. To do this, we'll need to start an IPFS daemon.
134+
135+
```sh
136+
> ipfs daemon
95137
```
138+
139+
(Again, either `jsipfs` or `ipfs` works. I'll stop explaining that from here on out.)
140+
141+
You should see the Websocket address in the output:
142+
143+
```sh
96144
Initializing daemon...
97145
Swarm listening on /ip4/127.0.0.1/tcp/4001
98146
Swarm listening on /ip4/127.0.0.1/tcp/9999/ws
@@ -103,7 +151,16 @@ Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
103151
Daemon is ready
104152
```
105153

106-
If you see address like `Swarm listening on /ip4/127.0.0.1/tcp/9999/ws`, it means all good!
154+
It's there in line 5 - see the `/ws`? Good. that means it is listening.
155+
156+
157+
### 4. Create the frame for your IPFS enabled app
158+
### 5. Add and cat a file
159+
### 6. Use WebRTC to dial between browser nodes
160+
### 7. Dial to a node using WebSockets (your Desktop ones)
161+
### 8. Transfer files between all of your nodes, have fun!
162+
163+
--------
107164

108165
## Start the example
109166

0 commit comments

Comments
 (0)