diff --git a/packages/rpc-proxy/README.md b/packages/rpc-proxy/README.md index 5c83e271d..e4127cf70 100644 --- a/packages/rpc-proxy/README.md +++ b/packages/rpc-proxy/README.md @@ -14,7 +14,6 @@ To install the RPC proxy, use the following command: ``` bash yarn add @vechain/sdk-rpc-proxy -rpc-proxy ``` ## Usage @@ -22,20 +21,25 @@ rpc-proxy The RPC proxy is simple to use. To start it, run: ``` bash -rpc-proxy +npx rpc-proxy ``` -By default, the proxy is configured to be used with a solo node running on your local machine. If you want to change the -default behavior, create a config.json file and pass it to the command when launching the RPC Proxy: +By default, the proxy is configured to be used with a solo node running on your local machine. There are two options if you want to change the default behavior, or use a custom configuration: + - Create a config.json file and pass it to the command when launching the RPC Proxy. + - Use CLI options. + +## Configuration file + +Run: ``` bash -rpc-proxy -c +npx rpc-proxy -c ``` Or: ``` bash -rpc-proxy --configurationFile +npx rpc-proxy --configurationFile ``` ## CLI Options @@ -45,41 +49,40 @@ Cli options override the configuration file. So you can run the rpc-proxy with: - a configuration file with the default values and override them with the cli options - - -e.g.- `rpc-proxy -p 8545 -v ...` + - -e.g.- `npx rpc-proxy -p 8545 -v ...` - a custom configuration file and override some values with the cli options - - -e.g.- `rpc-proxy -c /path/of/custom-config.json -p 8545 -v ...` + - -e.g.- `npx rpc-proxy -c /path/of/custom-config.json -p 8545 -v ...` ### Cli options list #### Give the configuration file - `-c, --configurationFile `: The path to the configuration file. - - -e.g.- `rpc-proxy -c /path/of/custom-config.json` OR `rpc-proxy --configurationFile custom-config.json` + - -e.g.- `npx rpc-proxy -c /path/of/custom-config.json` OR `rpc-proxy --configurationFile custom-config.json` - `-p, --port `: The port on which the proxy server will run. - - -e.g.- `rpc-proxy -p 8545` OR `rpc-proxy --port 8545` + - -e.g.- `npx rpc-proxy -p 8545` OR `rpc-proxy --port 8545` - `-u, --url `: The URL of the VeChain Thor node. - - -e.g.- `rpc-proxy -u http://testnet.vechain.org` OR `rpc-proxy --url http://testnet.vechain.org` + - -e.g.- `npx rpc-proxy -u http://testnet.vechain.org` OR `rpc-proxy --url http://testnet.vechain.org` - `-v, --verbose`: Whether to enable verbose logging. - - -e.g.- `rpc-proxy -v` OR `rpc-proxy --verbose` + - -e.g.- `npx rpc-proxy -v` OR `rpc-proxy --verbose` #### Give the accounts - `-a, --accounts `: The accounts (private keys) that the proxy server will use to sign transactions. It is a space-separated list of private keys. - - - -e.g.- `rpc-proxy -a "7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158"` - OR `rpc-proxy --accounts "7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158"` + - -e.g.- `npx rpc-proxy -a "7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158"` + OR `npx rpc-proxy --accounts "7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158"` - `-m, --mnemonic `: The mnemonic that the proxy server will use to sign transactions. - `-mc, --mnemonicCount `: The number of accounts to derive from the mnemonic. - `-mi, --mnemonicInitialIndex `: The index from which to start deriving accounts from the mnemonic. - - -e.g.- `rpc-proxy -m "denial kitchen pet squirrel other broom bar gas better priority spoil cross" -mc 10 -mi 1` - OR `rpc-proxy --mnemonic "denial kitchen pet squirrel other broom bar gas better priority spoil cross" --mnemonicCount 10 --mnemonicInitialIndex 1` + - -e.g.- `npx rpc-proxy -m "denial kitchen pet squirrel other broom bar gas better priority spoil cross" -mc 10 -mi 1` + OR `npx rpc-proxy --mnemonic "denial kitchen pet squirrel other broom bar gas better priority spoil cross" --mnemonicCount 10 --mnemonicInitialIndex 1` - **NOTE**: --mnemonic, --mnemonicCount, and --mnemonicInitialIndex MUST be used together. #### Use delegation @@ -87,26 +90,14 @@ So you can run the rpc-proxy with: - `-e, --enableDelegation`: Whether to enable delegation. - `-dp, --delegatorPrivateKey `: The private key of the delegator. - `-du, --delegatorUrl `: The URL of the delegator. - - -e.g.- `rpc-proxy -e -dp 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158` - OR `rpc-proxy --enableDelegation --delegatorPrivateKey 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158` - - -e.g.- `rpc-proxy -e -du https://sponsor-testnet.vechain.energy/by/...` - OR `rpc-proxy --enableDelegation --delegatorUrl https://sponsor-testnet.vechain.energy/by/...` + - -e.g.- `npx rpc-proxy -e -dp 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158` + OR `npx rpc-proxy --enableDelegation --delegatorPrivateKey 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158` + - -e.g.- `npx rpc-proxy -e -du https://sponsor-testnet.vechain.energy/by/...` + OR `npx rpc-proxy --enableDelegation --delegatorUrl https://sponsor-testnet.vechain.energy/by/...` - **NOTE**: --delegatorPrivateKey and --delegatorUrl are mutually exclusive. - **NOTE**: if --enableDelegation is used, --delegatorPrivateKey OR --delegatorUrl MUST be used. -# Run as Docker Container - -To run the RPC proxy as a Docker container, follow these steps: - -``` bash -docker build . -t vechain-rpc-proxy -docker run -d -p 8545:8545 -v ./config.json:/app/config.json -t vechain-rpc-proxy -``` - -If you do not pass a config.json file, the default solo network standard configuration will be used. Make sure to -provide your desired configuration file. - -## Configuration +## Configuration file The `config.json` file is used to configure the proxy server. It contains the following fields: @@ -184,4 +175,16 @@ Simple testnet configuration with a delegator private url: }, "enableDelegation": true } -``` \ No newline at end of file +``` + +# Run as Docker Container + +To run the RPC proxy as a Docker container, follow these steps: + +``` bash +docker build . -t vechain-rpc-proxy +docker run -d -p 8545:8545 -v ./config.json:/app/config.json -t vechain-rpc-proxy +``` + +If you do not pass a config.json file, the default solo network standard configuration will be used. Make sure to +provide your desired configuration file.