# Net

## net\_join

Instructs the client to join a network. The client sends a Handshake message to the addresses and adds them as peers if the handshake was successful.&#x20;

{% hint style="info" %}
**Private**: Requires authentication.
{% endhint %}

**Parameters**

| Argument  | Type           | Description          |
| --------- | -------------- | -------------------- |
| addresses | Array\<String> | A list of addresses. |

**Curl Example:**&#x20;

```bash
curl -X POST --data '{
    "jsonrpc":"2.0", 
    "method":"net_join", 
    "params": [
        "ellcrys://12D3KooWHHzSeKaY8xuZVzkLbKFfvNgPPeKhFBGrMbNzbm5akpqu@127.0.0.1:9000"
    ],
    "id":21
}'
```

#### Console Example

```javascript
> net.join(["ellcrys://12D3KooWHHzSeKaY8xuZVzkLbKFfvNgPPeKhFBGrMbNzbm5akpqu@127.0.0.1:9000"])
> net.join(
    "ellcrys://12D3KooWHHzS...zbm5akpqu@127.0.0.1:9000", 
    "ellcrys://12D3Koo..KhFBGrMbNzbagskuda@127.0.0.1:9000"
)
```

#### Returns:

`Boolean`&#x20;

#### Output:

```javascript
{
  "id": 8534968035807551000,
  "jsonrpc": "2.0",
  "result": true
}    
```

## net\_addPeer

Add one or more addresses to the peer list. These addresses will be lazily connected to only when the client needs more peer connections.&#x20;

{% hint style="info" %}
**Private**: Requires authentication.
{% endhint %}

**Parameters**

| Argument  | Type           | Description          |
| --------- | -------------- | -------------------- |
| addresses | Array\<String> | A list of addresses. |

**Curl Example:**&#x20;

```bash
curl -X POST --data '{
    "jsonrpc":"2.0", 
    "method":"net_addPeer", 
    "params": [
        "ellcrys://12D3KooWHHzSeKaY8xuZVzkLbKFfvNgPPeKhFBGrMbNzbm5akpqu@127.0.0.1:9000"
    ],
    "id":21
}'
```

#### Console Example

```javascript
> net.addPeer(["ellcrys://12D3KooWHHzSeKaY8xuZVzkLbKFfvNgPPeKhFBGrMbNzbm5akpqu@127.0.0.1:9000"])
> net.addPeer(
    "ellcrys://12D3KooWHHzS...zbm5akpqu@127.0.0.1:9000", 
    "ellcrys://12D3Koo..KhFBGrMbNzbagskuda@127.0.0.1:9000"
)
```

#### Returns:

`Boolean`&#x20;

#### Output:

```javascript
{
  "id": 8534968035807551000,
  "jsonrpc": "2.0",
  "result": true
}    
```

## net\_stats

Get the client's connection statistics.&#x20;

**Parameters**

**Curl Example:**&#x20;

```bash
curl -X POST --data '{"jsonrpc":"2.0",  "method":"net_stats", "id":21 }'
```

#### Console Example

```javascript
> net.stats()
```

#### Returns:

`Object`&#x20;

| Field    | Type    | Description                            |
| -------- | ------- | -------------------------------------- |
| inbound  | Integer | The number of inbound connections.     |
| outbound | Integer | The number of outbound connections.    |
| intros   | Integer | The number of intro messages received. |
| total    | Integer | The total number of connections.       |

#### Output:

```javascript
{
  "id": 7082198080470856000,
  "jsonrpc": "2.0",
  "result": {
    "inbound": 5,
    "intros": 3,
    "outbound": 6,
    "total": 9
  }
}  
```

## net\_getPeers

Get all known peers.

**Parameters**

**Curl Example:**&#x20;

```bash
curl -X POST --data '{"jsonrpc":"2.0",  "method":"net_getPeers", "id":21 }'
```

#### Console Example

```javascript
> net.getPeers()
```

#### Returns:

`Array<Object>`&#x20;

| Field        | Type    | Description                                                                                         |
| ------------ | ------- | --------------------------------------------------------------------------------------------------- |
| id           | String  | The ID of the peer.                                                                                 |
| name         | String  | The node's user-friendly name.                                                                      |
| connected    | Boolean | Indicates that the local peer is connected to the peer or not.                                      |
| isInbound    | Boolean | Indicates that the connection to this peer is inbound or not.                                       |
| isBanned     | Boolean | Indicates that the peer is currently banned or not.                                                 |
| isAcquainted | Boolean | <p>Indicates that the peer and the local peer have</p><p>performed the Handshake ritual or not.</p> |
| banEndTime   | String  | The time this peer will complete its ban term.                                                      |
| lastSeen     | String  | The time this peer was last heard from.                                                             |

#### Output:

```javascript
{
  "id": 21,
  "jsonrpc": "2.0",
  "result": [
    {
      "name": "normally-liked-eel",
      "banEndTime": "0001-01-01T00:00:00Z",
      "connected": true,
      "id": "12D3KooWHHzSeKaY8xuZVzkLbKFfvNgPPeKhFBGrMbNzbm5akpqu",
      "isAcquainted": true,
      "isBanned": false,
      "isInbound": false,
      "lastSeen": "2018-11-10T15:05:46.915069009+01:00"
    }
  ]
}
```

## net\_getActivePeers

Get all active peers. Active peers are peers that are not serving any ban time and have been seen in the last 3 hours.&#x20;

**Parameters**

**Curl Example:**&#x20;

```bash
curl -X POST --data '{"jsonrpc":"2.0",  "method":"net_getActivePeers", "id":21 }'
```

#### Console Example

```javascript
> net.getActivePeers()
```

#### Returns:

`Array<Object>`&#x20;

| Field        | Type    | Description                                                                                         |
| ------------ | ------- | --------------------------------------------------------------------------------------------------- |
| id           | String  | The ID of the peer.                                                                                 |
| name         | String  | The node's user-friendly name.                                                                      |
| connected    | Boolean | Indicates that the local peer is connected to the peer or not.                                      |
| isInbound    | Boolean | Indicates that the connection to this peer is inbound or not.                                       |
| isBanned     | Boolean | Indicates that the peer is currently banned or not.                                                 |
| isAcquainted | Boolean | <p>Indicates that the peer and the local peer have</p><p>performed the Handshake ritual or not.</p> |
| banEndTime   | String  | The time this peer will complete its ban term.                                                      |
| lastSeen     | String  | The time this peer was last heard from.                                                             |

#### Output:

```javascript
{
  "id": 21,
  "jsonrpc": "2.0",
  "result": [
    {
      "name": "normally-liked-eel",
      "banEndTime": "0001-01-01T00:00:00Z",
      "connected": true,
      "id": "12D3KooWHHzSeKaY8xuZVzkLbKFfvNgPPeKhFBGrMbNzbm5akpqu",
      "isAcquainted": true,
      "isBanned": false,
      "isInbound": false,
      "lastSeen": "2018-11-10T15:05:46.915069009+01:00"
    }
  ]
}
```

## net\_dumpPeers

Clear all peers stored in memory and on disk.

**Parameters**

**Curl Example:**&#x20;

```bash
curl -X POST --data '{"jsonrpc":"2.0",  "method":"net_dumpPeers", "id":21 }'
```

#### Console Example

```javascript
> net.dumpPeers()
```

#### Returns:

`Boolean`&#x20;

#### Output:

```javascript
{
  "id": 21,
  "jsonrpc": "2.0",
  "result": true
}
```

## net\_broadcasters

Returns the addresses of peers that have been selected by the peer as recipients of messages (transactions, blocks, addresses e.t.c) that need to be broadcast or forwarded. These broadcasters are separated into two categories namely:&#x20;

* Regular broadcasters
* Random broadcasters

Regular broadcasters are peers that are actively connected and known by the node. They are acquainted and compatible with the node. Random broadcasters may not be known or compatible with the node. They are mostly used for broadcasting addresses to aid the network's discovery protocol.

**Parameters**

**Curl Example:**&#x20;

```bash
curl -X POST --data '{"jsonrpc":"2.0",  "method":"net_broadcasters", "id":21 }'
```

#### Console Example

```javascript
> net.broadcasters()
```

#### Returns:

`Object`&#x20;

| Field              | Type           | Description                             |
| ------------------ | -------------- | --------------------------------------- |
| broadcasters       | Array\<string> | A list of regular broadcasters address. |
| randomBroadcasters | Array\<string> | A list of random broadcasters address.  |

#### Output:

```javascript
{
  "id": 21,
  "jsonrpc": "2.0",
  "result": {
    "broadcasters": [
      "ellcrys://12D3KooWDWA4g8EXWWBSbW...7nCDnbVADP1@127.0.0.1:9000",
      "ellcrys://12D3KooWCQgfHv8..fWvmwCPninVXpifMP@127.0.0.1:9000",
      "ellcrys://12D3KooWD276x1iei...S6AT2uAkHHFNADRx@127.0.0.1:9000"
    ],
    "randomBroadcasters": [
      "ellcrys://12D3KooWDWA4g8EXW..CDnbVADP1@127.0.0.1:9000",
      "ellcrys://12D3KooWCQgfH...b36BfWvmwCPninVXpifMP@127.0.0.1:9000",
      "ellcrys://12D3KooWD276x1ieiV9cmt...FNADRx@127.0.0.1:9000"
    ]
  }
}

```

## net\_noNet

Disables network activities. Prevents inbound or outbound connections by shutting down the client's network function. &#x20;

{% hint style="info" %}
**Private**: Requires authentication.
{% endhint %}

**Parameters:** Nonde

**Curl Example:**&#x20;

```bash
curl -X POST --data '{
    "jsonrpc":"2.0", 
    "method":"net_noNet", 
    "params": null,
    "id":21
}'
```

#### Console Example

```javascript
> net.noNet()
```

#### Returns:

`Boolean`&#x20;

#### Output:

```javascript
{
  "id": 8534968035807551000,
  "jsonrpc": "2.0",
  "result": true
}    
```
