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
Copy file name to clipboardExpand all lines: swarm/services/ens/README.md
+11-51Lines changed: 11 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,71 +2,41 @@
2
2
3
3
## Usage
4
4
5
-
Full documentation for the Ethereum Name Service [can be found as EIP]()
5
+
Full documentation for the Ethereum Name Service [can be found as EIP 137](https://github.com/ethereum/EIPs/issues/137)
6
6
Swarm offers a simple phase-one interface that streamlines the registration of swarm content hashes to arbitrary utf8 domain names.
7
7
The interface is offered through the ENS RPC API module under the `ens` namespace. The API can be used via the console, rpc or web3.js.
8
8
9
-
### `ens.deployRegistrar()`
9
+
### `ens.register(name)`
10
10
11
-
sends a contract creation transaction from your bzz account deploying an open registrar contract which can serve as ENS root resolver. A root resolver is deployed on the testnet and set as default for EnsRoot. Alternative can be given by changing the `ENSRoot` parameter in swarm `config.json` file.
11
+
Sends a transaction that registers a name as a top-level domain, giving ownership to the current account, and automatically deploying a simple resolver contract for it.
12
12
13
-
To deploy an alternative top-level domain root resolver:
13
+
This line registers the top-level domain `swarm`:
14
14
15
-
```js
16
-
registrarAddr=ens.deployRegistrar()
17
-
// "0xa90b9572f094660f8f314b591a365985e98d2fd0"
18
-
eth.getCode(registrarAddr) // check if contract was successfully deployed
19
-
// "0x" // not mined yet
20
-
// miner.start(1) // to start mining on a private chain
21
-
// true
22
15
```
23
-
24
-
### `ens.deployResolver()`
25
-
26
-
sends a contract creation transaction from your bzz account deploying a simple personal resolver contract, that can be registered with a (sub)domain on the root resolver. As a result the root resolver will delegate all hostnames under that domain to the child resolver.
27
-
28
-
To deploy a personal resolver:
29
-
30
-
```js
31
-
resolverAddr =ens.deployResolver()
32
-
// "0x2ba72b924a7d654c54467f7bda035ddc2f6fb4eb"
33
-
eth.getCode(registrarAddr) // check if contract was successfully deployed
34
-
// "0x" // not mined yet
35
-
// miner.start(1) // to start mining on a private chain
36
-
// true
37
-
```
38
-
39
-
### `ens.register(name, address)`
40
-
41
-
Sends a transaction that registers a resolver contract with domain on the top-level resolver.
42
-
As a result the bzz account becomes the owner of that domain.
43
-
This line registers the (already deployed) personal resolver at address `resolverAddr` to the top-level domain `swarm`
44
-
45
-
```
46
-
ens.register("swarm",resolverAddr)
16
+
ens.register("swarm")
47
17
// {}
48
18
```
49
19
50
20
### `ens.setContentHash(name, hash)`
51
21
52
-
sends a transaction that sets a content hash to a name using a (sub-domain) resolver:
22
+
Sends a transaction that sets a content hash to a name using a (sub-domain) resolver:
The content hash argument is the bzz hash as returned by a swarm upload, e.g., using `bzz.upload`:
60
-
The name here will allow the name setting, if the top-level domain is 'swarm', it dispatches to the
61
-
resolver just registered.
29
+
To function, the domain must have a resolver deployed that supports the `setContent` function, and the sending account must have permission to call that function. `ens.register()` deploys a resolver for you that meets this requirement.
30
+
31
+
The content hash argument is the bzz hash as returned by a swarm upload, e.g., using `bzz.upload`. The name here will allow the name setting, if the top-level domain is 'swarm', it dispatches to the resolver just registered.
62
32
63
33
```js
64
34
bzz.upload("path/to/my/directory", "index.html")
65
35
```
66
36
67
37
Here the second argument to `bzz.upload` is the relative path to the asset mapped on to the root hash of entire collection, effectively the landing page served on the bare hash (and therefore the root of the domain registered with that hash) as url.
@@ -88,20 +58,10 @@ This same backend method is used within swarm to resolve hostnames in urls, henc
88
58
89
59
## Development
90
60
91
-
The ABI and BIN files in contract subdirectory implement simple registrar and personal resolver contracts; they're used in tests, and can be used to deploy these contracts for your own purposes.
61
+
The SOL file in contract subdirectory implements the ENS root registry, a simple first-in-first-served registrar for the root namespace, and a simple resolver contract; they're used in tests, and can be used to deploy these contracts for your own purposes.
92
62
93
63
The solidity source code can be found at [github.com/arachnid/ens/](https://github.com/arachnid/ens/).
94
64
95
-
The ABI and BIN files in the contract subdirectory were generated by
using the .sol files in [revision 1cbd90d0631e8e30e1c28a394c128e7503ea85c6](https://github.com/Arachnid/ens/commit/1cbd90d0631e8e30e1c28a394c128e7503ea85c6)
103
-
with solc version 0.3.2-e3c54185
104
-
105
65
The go bindings for ENS contracts are generated using `abigen` via the go generator:
0 commit comments