# mainbridge

`mainbridge` namespace는 서비스체인과 관련된 함수를 제공합니다. 이 네임스페이스에서 함수를 사용하려면, 메인체인(메인넷 또는 Baobab 테스트넷)에 연결된 EN에서 `mainbridge` 옵션이 활성화되어 있어야 합니다).

## mainbridge\_nodeInfo <a href="#mainbridge_nodeinfo" id="mainbridge_nodeinfo"></a>

노드의 KNI (Klaytn Network Identifier)를 포함하여 브리지 노드 정보를 반환합니다. 메인브리지 노드는 KNI를 통해 서브브리지 노드에 연결할 수 있습니다.

**Parameters**

None

**Return Value**

| Type        | Description       |
| ----------- | ----------------- |
| JSON string | 브리지 노드에 대한 정보입니다. |

**Example**

```javascript
> mainbridge.nodeInfo
{
  kni: "kni://f8a1f0cd1e2bebeece571e4fda16e215218fd4b9bc2eddd924f7cd5b5f950fcec8f4b8cd3851390d1d0bacf1b15e1c4a38c882252e429a28d16eeb6edbacd726@[::]:50505?discport=0",
  id: "f8a1f0cd1e2bebeece571e4fda16e215218fd4b9bc2eddd924f7cd5b5f950fcec8f4b8cd3851390d1d0bacf1b15e1c4a38c882252e429a28d16eeb6edbacd726",
  ip: "::",
  listenAddr: "[::]:50505",
  name: "-2",
  ports: {
    discovery: 0,
    listener: 50505
  },
  protocols: {
    servicechain: {
      config: {
        chainId: 2018,
        deriveShaImpl: 0,
        isBFT: true,
        istanbul: {...},
        unitPrice: 0
      },
      difficulty: 87860,
      genesis: "0x711ce9865492659977abb2758d29f68c2b0c82862d9376f25953579f64f95b58",
      head: "0x0d4b130731f1e7560e4531ac73d55ac8c6daccb178abd86af0d96b7aafded7c5",
      network: 1
    }
  }
}
```

## mainbridge\_addPeer <a href="#mainbridge_addpeer" id="mainbridge_addpeer"></a>

서브브리지 피어 추가가 성공적으로 완료되면 `true`를 반환합니다.

피어 목록에 새 원격 노드를 추가합니다. The node will try to maintain connectivity to these nodes at all times, reconnecting every once in a while if the remote connection goes down. 이 메소드는 추적을 시작하기 위해 하나의 인자로 원격 피어의 `kni` URL를 받고, 피어 추적이 허용되었는지 또는 어떤 오류가 발생했는지를 나타내는 `BOOL`을 반환합니다.

**Parameters**

| Name | Type   | Description       |
| ---- | ------ | ----------------- |
| url  | string | 피어의 `kni` URL입니다. |

**Return Value**

| Type | Description                                         |
| ---- | --------------------------------------------------- |
| bool | `true` if the peer was accepted, `false` otherwise. |

**Example**

Console

```javascript
> mainbridge.addPeer("kni://a979fb...1163c@10.0.0.1:50505") // or 'subbridge.addPeer'
true
```

HTTP RPC

```shell
$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"mainbridge_addPeer","params":["kni://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@10.0.0.1:50505"],"id":1}' https://public-en-baobab.klaytn.net
{"jsonrpc":"2.0","id":1,"result":true}
```

## mainbridge\_removePeer <a href="#mainbridge_removepeer" id="mainbridge_removepeer"></a>

피어 제거가 성공적으로 완료되면 `true`를 반환합니다.

`removePeer` 메소드는 추적된 정적 노드 목록에서 원격 노드의 연결을 끊고 제거합니다. 이 메소드는 추적을 시작하기 위해 하나의 인자로 원격 피어의 `kni` URL를 받고, 피어 추적이 허용되었는지 또는 어떤 오류가 발생했는지를 나타내는 `BOOL`을 반환합니다.

**Parameters**

| Name | Type   | Description       |
| ---- | ------ | ----------------- |
| url  | string | Peer's `kni` URL. |

**Return Value**

| Type | Description                                    |
| ---- | ---------------------------------------------- |
| bool | 피어가 제거되면 `true`를 반환하고, 그렇지 않으면 `false`를 반환합니다. |

**Example**

Console

```javascript
> mainbridge.removePeer("kni://a979fb...1163c@10.0.0.1:50505") // or 'subbridge.removePeer'
true
```

HTTP RPC

```shell
$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"mainbridge_removePeer","params":["kni://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@10.0.0.1:50505"],"id":1}' https://public-en-baobab.klaytn.net
{"jsonrpc":"2.0","id":1,"result":true}
```

## mainbridge\_getChildChainIndexingEnabled <a href="#mainbridge_getchildchainindexingenabled" id="mainbridge_getchildchainindexingenabled"></a>

`mainbridge_getChildChainIndexingEnabled`는 앵커링 트랜잭션의 인덱싱이 활성화되어 있는지 여부를 반환합니다.

**Parameters**

none

**Return Value**

| Type | Description                                   |
| ---- | --------------------------------------------- |
| bool | 인덱싱이 활성화된 경우 `true`를, 그렇지 않으면 `false`를 반환합니다. |

**Example**

```javascript
> mainbridge.getChildChainIndexingEnabled()
true
```

## mainbridge\_convertChildChainBlockHashToParentChainTxHash <a href="#mainbridge_convertchildchainblockhashtoparentchaintxhash" id="mainbridge_convertchildchainblockhashtoparentchaintxhash"></a>

주어진 자식 체인 블록 해시의 앵커링 트랜잭션 해시를 반환합니다.

**Parameters**

| Type         | Description      |
| ------------ | ---------------- |
| 32-byte DATA | 자식 체인의 블록 해시입니다. |

**Return Value**

| Type         | Description                       |
| ------------ | --------------------------------- |
| 32-byte DATA | 자식 체인의 블록 정보가 포함된 앵커링 트랜잭션 해시입니다. |

**Example**

Console

```javascript
> mainbridge.convertChildChainBlockHashToParentChainTxHash("0xeadc6a3a29a20c13824b5df1ba05cca1ed248d046382a4f2792aac8a6e0d1880")
"0x9a68591c0faa138707a90a7506840c562328aeb7621ac0561467c371b0322d51"
```

HTTP RPC

```shell
$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"mainbridge_convertChildChainBlockHashToParentChainTxHash","params":["0xeadc6a3a29a20c13824b5df1ba05cca1ed248d046382a4f2792aac8a6e0d1880"],"id":1}' https://public-en-baobab.klaytn.net
{"jsonrpc":"2.0","id":1,"result":"0x9a68591c0faa138707a90a7506840c562328aeb7621ac0561467c371b0322d51"}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://archive-ko.docs.klaytn.foundation/content/dapp/json-rpc/servicechain/mainbridge.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
