Skip to content

Admin

Entity Version
Source 1.12.14-unstable/generated-at:2023-09-04T08:02:34-06:00
OpenRPC 1.2.6

admin_addPeer

AddPeer requests connecting to a remote node, and also maintaining the new connection at all times, even reconnecting if it is lost.

Params (1)

Parameters must be given by position.

1: url string

  • Required: ✓ Yes

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_addPeer", "params": [<url>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_addPeer", "params": [<url>]}'
1
admin.addPeer(url);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
func (api *adminAPI) AddPeer(url string) (bool, error) {
    server := api.node.Server()
    if server == nil {
        return false, ErrNodeStopped
    }
    node, err := enode.Parse(enode.ValidSchemes, url)
    if err != nil {
        return false, fmt.Errorf("invalid enode: %v", err)
    }
    server.AddPeer(node)
    return true, nil
}// AddPeer requests connecting to a remote node, and also maintaining the new
// connection at all times, even reconnecting if it is lost.
View on GitHub →


admin_addTrustedPeer

AddTrustedPeer allows a remote node to always connect, even if slots are full

Params (1)

Parameters must be given by position.

1: url string

  • Required: ✓ Yes

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_addTrustedPeer", "params": [<url>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_addTrustedPeer", "params": [<url>]}'
1
admin.addTrustedPeer(url);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
func (api *adminAPI) AddTrustedPeer(url string) (bool, error) {
    server := api.node.Server()
    if server == nil {
        return false, ErrNodeStopped
    }
    node, err := enode.Parse(enode.ValidSchemes, url)
    if err != nil {
        return false, fmt.Errorf("invalid enode: %v", err)
    }
    server.AddTrustedPeer(node)
    return true, nil
}// AddTrustedPeer allows a remote node to always connect, even if slots are full
View on GitHub →


admin_datadir

Datadir retrieves the current data directory the node is using.

Params (0)

None

Result

string

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_datadir", "params": []}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_datadir", "params": []}'
1
admin.datadir();
Source code

1
2
3
func (api *adminAPI) Datadir() string {
    return api.node.DataDir()
}// Datadir retrieves the current data directory the node is using.
View on GitHub →


admin_ecbp1100

Params (1)

Parameters must be given by position.

1: blockNr rpc.BlockNumber

  • Required: ✓ Yes
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
- oneOf: 

        - description: `The block height description`
        - enum: earliest, latest, pending
        - title: `blockNumberTag`
        - type: string


        - description: `Hex representation of a uint64`
        - pattern: `^0x([a-fA-F\d])+$`
        - title: `uint64`
        - type: string


- title: `blockNumberIdentifier`
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
    "oneOf": [
        {
            "description": "The block height description",
            "enum": [
                "earliest",
                "latest",
                "pending"
            ],
            "title": "blockNumberTag",
            "type": [
                "string"
            ]
        },
        {
            "description": "Hex representation of a uint64",
            "pattern": "^0x([a-fA-F\\d])+$",
            "title": "uint64",
            "type": [
                "string"
            ]
        }
    ],
    "title": "blockNumberIdentifier"
}

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_ecbp1100", "params": [<blockNr>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_ecbp1100", "params": [<blockNr>]}'
1
admin.ecbp1100(blockNr);
Source code

1
2
3
4
5
func (api *AdminAPI) Ecbp1100(blockNr rpc.BlockNumber) (bool, error) {
    i := uint64(blockNr.Int64())
    err := api.eth.blockchain.Config().SetECBP1100Transition(&i)
    return api.eth.blockchain.IsArtificialFinalityEnabled() && api.eth.blockchain.Config().IsEnabled(api.eth.blockchain.Config().GetECBP1100Transition, api.eth.blockchain.CurrentBlock().Number), err
}
View on GitHub →


admin_exportChain

ExportChain exports the current blockchain into a local file, or a range of blocks if first and last are non-nil.

Params (3)

Parameters must be given by position.

1: file string

  • Required: ✓ Yes

2: first *uint64

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}

3: last *uint64

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_exportChain", "params": [<file>, <first>, <last>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_exportChain", "params": [<file>, <first>, <last>]}'
1
admin.exportChain(file,first,last);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
func (api *AdminAPI) ExportChain(file string, first *uint64, last *uint64) (bool, error) {
    if first == nil && last != nil {
        return false, errors.New("last cannot be specified without first")
    }
    if first != nil && last == nil {
        head := api.eth.BlockChain().CurrentHeader().Number.Uint64()
        last = &head
    }
    if _, err := os.Stat(file); err == nil {
        return false, errors.New("location would overwrite an existing file")
    }
    out, err := os.OpenFile(file, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
    if err != nil {
        return false, err
    }
    defer out.Close()
    var writer io.Writer = out
    if strings.HasSuffix(file, ".gz") {
        writer = gzip.NewWriter(writer)
        defer writer.(*gzip.Writer).Close()
    }
    if first != nil {
        if err := api.eth.BlockChain().ExportN(writer, *first, *last); err != nil {
            return false, err
        }
    } else if err := api.eth.BlockChain().Export(writer); err != nil {
        return false, err
    }
    return true, nil
}// ExportChain exports the current blockchain into a local file,
// or a range of blocks if first and last are non-nil.
View on GitHub →


admin_importChain

ImportChain imports a blockchain from a local file.

Params (1)

Parameters must be given by position.

1: file string

  • Required: ✓ Yes

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_importChain", "params": [<file>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_importChain", "params": [<file>]}'
1
admin.importChain(file);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
func (api *AdminAPI) ImportChain(file string) (bool, error) {
    in, err := os.Open(file)
    if err != nil {
        return false, err
    }
    defer in.Close()
    var reader io.Reader = in
    if strings.HasSuffix(file, ".gz") {
        if reader, err = gzip.NewReader(reader); err != nil {
            return false, err
        }
    }
    stream := rlp.NewStream(reader, 0)
    blocks, index := make([ // ImportChain imports a blockchain from a local file.
    ]*types.Block, 0, 2500), 0
    for batch := 0; ; batch++ {
        for len(blocks) < cap(blocks) {
            block := new(types.Block)
            if err := stream.Decode(block); err == io.EOF {
                break
            } else if err != nil {
                return false, fmt.Errorf("block %d: failed to parse: %v", index, err)
            }
            blocks = append(blocks, block)
            index++
        }
        if len(blocks) == 0 {
            break
        }
        if hasAllBlocks(api.eth.BlockChain(), blocks) {
            blocks = blocks[:0]
            continue
        }
        if _, err := api.eth.BlockChain().InsertChain(blocks); err != nil {
            return false, fmt.Errorf("batch %d: failed to insert: %v", batch, err)
        }
        blocks = blocks[:0]
    }
    return true, nil
}
View on GitHub →


admin_maxPeers

MaxPeers sets the maximum peer limit for the protocol manager and the p2p server.

Params (1)

Parameters must be given by position.

1: n int

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_maxPeers", "params": [<n>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_maxPeers", "params": [<n>]}'
1
admin.maxPeers(n);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
func (api *AdminAPI) MaxPeers(n int) (bool, error) {
    api.eth.handler.maxPeers = n
    api.eth.p2pServer.MaxPeers = n
    for i := api.eth.handler.peers.len(); i > n; i = api.eth.handler.peers.len() {
        p := api.eth.handler.peers.WorstPeer()
        if p == nil {
            break
        }
        api.eth.handler.removePeer(p.ID())
    }
    return true, nil
}// MaxPeers sets the maximum peer limit for the protocol manager and the p2p server.
View on GitHub →


admin_nodeInfo

NodeInfo retrieves all the information we know about the host node at the protocol granularity.

Params (0)

None

Result

*p2p.NodeInfo

  • Required: ✓ Yes
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
- additionalProperties: `false`
- properties: 
    - enode: 
        - type: `string`

    - enr: 
        - type: `string`

    - id: 
        - type: `string`

    - ip: 
        - type: `string`

    - listenAddr: 
        - type: `string`

    - name: 
        - type: `string`

    - ports: 
        - additionalProperties: `false`
        - properties: 
            - discovery: 
                - pattern: `^0x[a-fA-F0-9]+$`
                - title: `integer`
                - type: `string`

            - listener: 
                - pattern: `^0x[a-fA-F0-9]+$`
                - title: `integer`
                - type: `string`


        - type: `object`

    - protocols: 
        - additionalProperties: `false`
        - properties: 
            - discovery: 
                - pattern: `^0x[a-fA-F0-9]+$`
                - title: `integer`
                - type: `string`

            - listener: 
                - pattern: `^0x[a-fA-F0-9]+$`
                - title: `integer`
                - type: `string`


        - type: `object`


- type: object
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{
    "additionalProperties": false,
    "properties": {
        "enode": {
            "type": "string"
        },
        "enr": {
            "type": "string"
        },
        "id": {
            "type": "string"
        },
        "ip": {
            "type": "string"
        },
        "listenAddr": {
            "type": "string"
        },
        "name": {
            "type": "string"
        },
        "ports": {
            "additionalProperties": false,
            "properties": {
                "discovery": {
                    "pattern": "^0x[a-fA-F0-9]+$",
                    "title": "integer",
                    "type": "string"
                },
                "listener": {
                    "pattern": "^0x[a-fA-F0-9]+$",
                    "title": "integer",
                    "type": "string"
                }
            },
            "type": "object"
        },
        "protocols": {
            "additionalProperties": false,
            "properties": {
                "discovery": {
                    "pattern": "^0x[a-fA-F0-9]+$",
                    "title": "integer",
                    "type": "string"
                },
                "listener": {
                    "pattern": "^0x[a-fA-F0-9]+$",
                    "title": "integer",
                    "type": "string"
                }
            },
            "type": "object"
        }
    },
    "type": [
        "object"
    ]
}

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_nodeInfo", "params": []}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_nodeInfo", "params": []}'
1
admin.nodeInfo();
Source code

1
2
3
4
5
6
7
8
func (api *adminAPI) NodeInfo() (*p2p.NodeInfo, error) {
    server := api.node.Server()
    if server == nil {
        return nil, ErrNodeStopped
    }
    return server.NodeInfo(), nil
}// NodeInfo retrieves all the information we know about the host node at the
// protocol granularity.
View on GitHub →


admin_peerEvents

PeerEvents creates an RPC subscription which receives peer events from the node’s p2p.Server

Params (0)

None

Result

*rpc.Subscription

  • Required: ✓ Yes
1
2
3
- description: `Subscription identifier`
- title: `subscriptionID`
- type: string
1
2
3
4
5
6
7
{
    "description": "Subscription identifier",
    "title": "subscriptionID",
    "type": [
        "string"
    ]
}

Client Method Invocation Examples

1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_subscribe", "params": ["peerEvents"]}'
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
func (api *adminAPI) PeerEvents(ctx context.Context) (*rpc.Subscription, error) {
    server := api.node.Server()
    if server == nil {
        return nil, ErrNodeStopped
    }
    notifier, supported := rpc.NotifierFromContext(ctx)
    if !supported {
        return nil, rpc.ErrNotificationsUnsupported
    }
    rpcSub := notifier.CreateSubscription()
    go func() {
        events := make(chan *p2p.PeerEvent)
        sub := server.SubscribeEvents(events)
        defer sub.Unsubscribe()
        for {
            select {
            case event := <-events:
                notifier.Notify(rpcSub.ID, event)
            case <-sub.Err():
                return
            case <-rpcSub.Err():
                return
            case <-notifier.Closed():
                return
            }
        }
    }()
    return rpcSub, nil
}// PeerEvents creates an RPC subscription which receives peer events from the
// node's p2p.Server
View on GitHub →


admin_peers

Peers retrieves all the information we know about each individual peer at the protocol granularity.

Params (0)

None

Result

p2pPeerInfo []*p2p.PeerInfo

  • Required: ✓ Yes
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- items: 

        - additionalProperties: `false`
        - properties: 
            - caps: 
                - items: 
                    - type: `string`

                - type: `array`

            - enode: 
                - type: `string`

            - enr: 
                - type: `string`

            - id: 
                - type: `string`

            - name: 
                - type: `string`

            - network: 
                - additionalProperties: `false`
                - properties: 
                    - inbound: 
                        - type: `boolean`

                    - localAddress: 
                        - type: `string`

                    - remoteAddress: 
                        - type: `string`

                    - static: 
                        - type: `boolean`

                    - trusted: 
                        - type: `boolean`


                - type: `object`

            - protocols: 
                - additionalProperties: `false`
                - properties: 
                    - inbound: 
                        - type: `boolean`

                    - localAddress: 
                        - type: `string`

                    - remoteAddress: 
                        - type: `string`

                    - static: 
                        - type: `boolean`

                    - trusted: 
                        - type: `boolean`


                - type: `object`


        - type: object


- type: array
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{
    "items": [
        {
            "additionalProperties": false,
            "properties": {
                "caps": {
                    "items": {
                        "type": "string"
                    },
                    "type": "array"
                },
                "enode": {
                    "type": "string"
                },
                "enr": {
                    "type": "string"
                },
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "network": {
                    "additionalProperties": false,
                    "properties": {
                        "inbound": {
                            "type": "boolean"
                        },
                        "localAddress": {
                            "type": "string"
                        },
                        "remoteAddress": {
                            "type": "string"
                        },
                        "static": {
                            "type": "boolean"
                        },
                        "trusted": {
                            "type": "boolean"
                        }
                    },
                    "type": "object"
                },
                "protocols": {
                    "additionalProperties": false,
                    "properties": {
                        "inbound": {
                            "type": "boolean"
                        },
                        "localAddress": {
                            "type": "string"
                        },
                        "remoteAddress": {
                            "type": "string"
                        },
                        "static": {
                            "type": "boolean"
                        },
                        "trusted": {
                            "type": "boolean"
                        }
                    },
                    "type": "object"
                }
            },
            "type": [
                "object"
            ]
        }
    ],
    "type": [
        "array"
    ]
}

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_peers", "params": []}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_peers", "params": []}'
1
admin.peers();
Source code

1
2
3
4
5
6
7
8
9
func (api *adminAPI) Peers() ([ // Peers retrieves all the information we know about each individual peer at the
// protocol granularity.
]*p2p.PeerInfo, error) {
    server := api.node.Server()
    if server == nil {
        return nil, ErrNodeStopped
    }
    return server.PeersInfo(), nil
}
View on GitHub →


admin_removePeer

RemovePeer disconnects from a remote node if the connection exists

Params (1)

Parameters must be given by position.

1: url string

  • Required: ✓ Yes

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_removePeer", "params": [<url>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_removePeer", "params": [<url>]}'
1
admin.removePeer(url);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
func (api *adminAPI) RemovePeer(url string) (bool, error) {
    server := api.node.Server()
    if server == nil {
        return false, ErrNodeStopped
    }
    node, err := enode.Parse(enode.ValidSchemes, url)
    if err != nil {
        return false, fmt.Errorf("invalid enode: %v", err)
    }
    server.RemovePeer(node)
    return true, nil
}// RemovePeer disconnects from a remote node if the connection exists
View on GitHub →


admin_removeTrustedPeer

RemoveTrustedPeer removes a remote node from the trusted peer set, but it does not disconnect it automatically.

Params (1)

Parameters must be given by position.

1: url string

  • Required: ✓ Yes

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_removeTrustedPeer", "params": [<url>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_removeTrustedPeer", "params": [<url>]}'
1
admin.removeTrustedPeer(url);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
func (api *adminAPI) RemoveTrustedPeer(url string) (bool, error) {
    server := api.node.Server()
    if server == nil {
        return false, ErrNodeStopped
    }
    node, err := enode.Parse(enode.ValidSchemes, url)
    if err != nil {
        return false, fmt.Errorf("invalid enode: %v", err)
    }
    server.RemoveTrustedPeer(node)
    return true, nil
}// RemoveTrustedPeer removes a remote node from the trusted peer set, but it
// does not disconnect it automatically.
View on GitHub →


admin_startHTTP

StartHTTP starts the HTTP RPC API server.

Params (5)

Parameters must be given by position.

1: host *string

  • Required: ✓ Yes

2: port *int

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}

3: cors *string

  • Required: ✓ Yes

4: apis *string

  • Required: ✓ Yes

5: vhosts *string

  • Required: ✓ Yes

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_startHTTP", "params": [<host>, <port>, <cors>, <apis>, <vhosts>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_startHTTP", "params": [<host>, <port>, <cors>, <apis>, <vhosts>]}'
1
admin.startHTTP(host,port,cors,apis,vhosts);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
func (api *adminAPI) StartHTTP(host *string, port *int, cors *string, apis *string, vhosts *string) (bool, error) {
    api.node.lock.Lock()
    defer api.node.lock.Unlock()
    if host == nil {
        h := DefaultHTTPHost
        if api.node.config.HTTPHost != "" {
            h = api.node.config.HTTPHost
        }
        host = &h
    }
    if port == nil {
        port = &api.node.config.HTTPPort
    }
    config := httpConfig{CorsAllowedOrigins: api.node.config.HTTPCors, Vhosts: api.node.config.HTTPVirtualHosts, Modules: api.node.config.HTTPModules, rpcEndpointConfig: rpcEndpointConfig{batchItemLimit: api.node.config.BatchRequestLimit, batchResponseSizeLimit: api.node.config.BatchResponseMaxSize}}
    if cors != nil {
        config.CorsAllowedOrigins = nil
        for _, origin := // StartHTTP starts the HTTP RPC API server.
        range strings.Split(*cors, ",") {
            config.CorsAllowedOrigins = append(config.CorsAllowedOrigins, strings.TrimSpace(origin))
        }
    }
    if vhosts != nil {
        config.Vhosts = nil
        for _, vhost := range strings.Split(*host, ",") {
            config.Vhosts = append(config.Vhosts, strings.TrimSpace(vhost))
        }
    }
    if apis != nil {
        config.Modules = nil
        for _, m := range strings.Split(*apis, ",") {
            config.Modules = append(config.Modules, strings.TrimSpace(m))
        }
    }
    if err := api.node.http.setListenAddr(*host, *port); err != nil {
        return false, err
    }
    if err := api.node.http.enableRPC(api.node.rpcAPIs, config); err != nil {
        return false, err
    }
    if err := api.node.http.start(); err != nil {
        return false, err
    }
    return true, nil
}
View on GitHub →


admin_startRPC

StartRPC starts the HTTP RPC API server. Deprecated: use StartHTTP instead.

Params (5)

Parameters must be given by position.

1: host *string

  • Required: ✓ Yes

2: port *int

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}

3: cors *string

  • Required: ✓ Yes

4: apis *string

  • Required: ✓ Yes

5: vhosts *string

  • Required: ✓ Yes

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_startRPC", "params": [<host>, <port>, <cors>, <apis>, <vhosts>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_startRPC", "params": [<host>, <port>, <cors>, <apis>, <vhosts>]}'
1
admin.startRPC(host,port,cors,apis,vhosts);
Source code

1
2
3
4
5
func (api *adminAPI) StartRPC(host *string, port *int, cors *string, apis *string, vhosts *string) (bool, error) {
    log.Warn("Deprecation warning", "method", "admin.StartRPC", "use-instead", "admin.StartHTTP")
    return api.StartHTTP(host, port, cors, apis, vhosts)
}// StartRPC starts the HTTP RPC API server.
// Deprecated: use StartHTTP instead.
View on GitHub →


admin_startWS

StartWS starts the websocket RPC API server.

Params (4)

Parameters must be given by position.

1: host *string

  • Required: ✓ Yes

2: port *int

  • Required: ✓ Yes
1
2
3
4
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
1
2
3
4
5
6
7
8
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}

3: allowedOrigins *string

  • Required: ✓ Yes

4: apis *string

  • Required: ✓ Yes

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_startWS", "params": [<host>, <port>, <allowedOrigins>, <apis>]}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_startWS", "params": [<host>, <port>, <allowedOrigins>, <apis>]}'
1
admin.startWS(host,port,allowedOrigins,apis);
Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
func (api *adminAPI) StartWS(host *string, port *int, allowedOrigins *string, apis *string) (bool, error) {
    api.node.lock.Lock()
    defer api.node.lock.Unlock()
    if host == nil {
        h := DefaultWSHost
        if api.node.config.WSHost != "" {
            h = api.node.config.WSHost
        }
        host = &h
    }
    if port == nil {
        port = &api.node.config.WSPort
    }
    config := wsConfig{Modules: api.node.config.WSModules, Origins: api.node.config.WSOrigins, rpcEndpointConfig: rpcEndpointConfig{batchItemLimit: api.node.config.BatchRequestLimit, batchResponseSizeLimit: api.node.config.BatchResponseMaxSize}}
    if apis != nil {
        config.Modules = nil
        for _, m := // StartWS starts the websocket RPC API server.
        range strings.Split(*apis, ",") {
            config.Modules = append(config.Modules, strings.TrimSpace(m))
        }
    }
    if allowedOrigins != nil {
        config.Origins = nil
        for _, origin := range strings.Split(*allowedOrigins, ",") {
            config.Origins = append(config.Origins, strings.TrimSpace(origin))
        }
    }
    server := api.node.wsServerForPort(*port, false)
    if err := server.setListenAddr(*host, *port); err != nil {
        return false, err
    }
    openApis, _ := api.node.getAPIs()
    if err := server.enableWS(openApis, config); err != nil {
        return false, err
    }
    if err := server.start(); err != nil {
        return false, err
    }
    api.node.http.log.Info("WebSocket endpoint opened", "url", api.node.WSEndpoint())
    return true, nil
}
View on GitHub →


admin_stopHTTP

StopHTTP shuts down the HTTP server.

Params (0)

None

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_stopHTTP", "params": []}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_stopHTTP", "params": []}'
1
admin.stopHTTP();
Source code

1
2
3
4
func (api *adminAPI) StopHTTP() (bool, error) {
    api.node.http.stop()
    return true, nil
}// StopHTTP shuts down the HTTP server.
View on GitHub →


admin_stopRPC

StopRPC shuts down the HTTP server. Deprecated: use StopHTTP instead.

Params (0)

None

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_stopRPC", "params": []}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_stopRPC", "params": []}'
1
admin.stopRPC();
Source code

1
2
3
4
5
func (api *adminAPI) StopRPC() (bool, error) {
    log.Warn("Deprecation warning", "method", "admin.StopRPC", "use-instead", "admin.StopHTTP")
    return api.StopHTTP()
}// StopRPC shuts down the HTTP server.
// Deprecated: use StopHTTP instead.
View on GitHub →


admin_stopWS

StopWS terminates all WebSocket servers.

Params (0)

None

Result

bool

  • Required: ✓ Yes

Client Method Invocation Examples

1
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_stopWS", "params": []}'
1
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_stopWS", "params": []}'
1
admin.stopWS();
Source code

1
2
3
4
5
func (api *adminAPI) StopWS() (bool, error) {
    api.node.http.stopWS()
    api.node.ws.stop()
    return true, nil
}// StopWS terminates all WebSocket servers.
View on GitHub →



Last update: 2023-10-11