diff --git a/src/eth/client.yaml b/src/eth/client.yaml index 416df4c0a..f3a9cca0f 100644 --- a/src/eth/client.yaml +++ b/src/eth/client.yaml @@ -70,3 +70,16 @@ result: name: Block number value: '0x2377' +- name: net_version + summary: Returns the current network ID. This is usually equivalent to the chainID, but may differ from it for some legacy networks or special testnets. + params: [] + result: + name: Network ID + schema: + $ref: '#/components/schemas/uintDecimal' + examples: + - name: net_version example + params: [] + result: + name: Network ID + value: '1' diff --git a/src/schemas/base-types.yaml b/src/schemas/base-types.yaml index 500d6c358..42d91b440 100644 --- a/src/schemas/base-types.yaml +++ b/src/schemas/base-types.yaml @@ -60,6 +60,10 @@ uint256: title: hex encoded 256 bit unsigned integer type: string pattern: ^0x(0|[1-9a-f][0-9a-f]{0,63})$ +uintDecimal: + title: decimal unsigned integer string + type: string + pattern: ^[1-9][0-9]*$ hash32: title: 32 byte hex value type: string diff --git a/tests/net_version/get-network-id.io b/tests/net_version/get-network-id.io new file mode 100644 index 000000000..03cab5e8b --- /dev/null +++ b/tests/net_version/get-network-id.io @@ -0,0 +1,3 @@ +// Calls net_version to retrieve the network ID, which is expected to be equal to the chainID of the test chain. +>> {"jsonrpc":"2.0","id":1,"method":"net_version"} +<< {"jsonrpc":"2.0","id":1,"result":"3503995874084926"}