Skip to content

Running golem-base op-geth Locally

If you prefer to run the golem-base op-geth locally, you can easily do so with minimal memory and disk space.

You have two options: You can run the op-gase node and several other services inside a docker container; or you can run just the op-geth node locally.

For information on how to run it in a docker container, go here.

Or, you can directly run the op-geth node outside of docker. To do that, you'll need to make sure you have the golang tools installed. Go doesn't rely on package managers; rather they use a straightforward way of downloading and unpacking the tools. Learn how here.

Then, you'll need to clone the repo here:

https://github.com/Golem-Base/golembase-op-geth

Next, the easiest way is to build the code and run it. Move into the root folder of the golembase-op-geth code. You can either paste the following into the shell, or copy it into a script file (such as geth_build.sh) and make the script executable; this line builds it:

go build ./cmd/geth

This will create a file in the current folder called geth. Then to run it, again either paste this in, or put it inside an executable script file (such as geth_run.sh); this line runs the code with the required "developer" mode:

./geth --dev --http --http.api 'eth,web3,net,debug,golembase' --verbosity 3 --http.addr '0.0.0.0' --http.port 8545 --http.corsdomain '*' --http.vhosts '*' --ws --ws.addr '0.0.0.0' --ws.port 8545

Building the Golem-base Command Line Tool

To build the command-line tool, again from the root of the golembase-op-geth folder, type:

go build ./cmd/golembase

This will create an executable file in the current folder called golembase.

Test it by typing:

./golembase --help

Creating a private key file

Use the above golembase command-line tool to create a private key file:

./golembase account create

This will create a private key file in the config area of your home directory (depending on your OS). The output will show the full path to the file, as well as the public address for the generated key. Here's a sample output:

privageKeyPath /home/freckleface/.config/golembase/private.key
Private key generated and saved to /home/freckleface/.config/golembase/private.key
Address: 0x6D107D3a163914Bd227F79D11c3b245B58167527

Initially your account is ready to go without any further configuration within op-geth. Ethereum nodes will immediately accept a proper address without you having to first "create an account" on the node.

That means your running node is ready to accept transactions from the address for the key you just created.

Adding funds to your account

Now you can add funds to the locally running node for the address you just created:

./golembase account fund 100

This will add 100 Eth to your local node. (But it's only a developer node with fake funds!)

Important: Data is not saved

The downside to running a local node in this manner (as opposed to using the docker container) is that if you stop the node (such as by pressing Ctrl-C), no data is saved. Please understand that!

So if you restart the node, you'll have to add funds again, as the fund data is gone.

Working with Our Samples

Please note that in many of our samples, we're not searching for the private.key file in the config area, but rather inside the local running directory. In such cases, you'll want to copy the private.key file to the folder as per the instructions accompanying the code sample.