1

I need to know how to configure a Geth node that I am running locally for the purpose of deploying smart contracts to in a test net context. I have the Geth source project setup successfully in JetBrains GoLand IDE on Linux. When I run the project, it compiles successfully, executes, but immediately exits with a 0 exit code instead of staying resident, ready to accept smart contract deployments and execution.

How do I configure my Geth node node for proper execution on Ubuntu Linux (14.04) and so I can deploy smart contracts to it from Truffle? Are there any web pages or resources that discuss this issue directly (Geth node configuration, launch, and smart contract deployment?)

1 Answer 1

2

With Truffle I use HTTP-RPC calls to deploy my contracts via geth:

  • --rpc should be provided in the CLI when starting geth to enable the HTTP-RPC server
  • by default the HTTP-RPC server will start on localhost:8545 (i.e. 127.0.0.1:8545), though you can change this with the CLI arguments --rpcaddr <new address> and --port <new port> respectively if you'd prefer, or change the appropriate fields in your config file if you configure geth that way.

As per the truffle documentation your truffle.js file then needs to point to this node:

networks: {
    <yourNetworkName>: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*", // i.e. run on any network your geth node is connected to
      //from: "0x<your address>", // if you want to deploy from a specific node address, otherwise it'll default to eth.accounts[0]
      gas: 4712388,  //default 4712388
      gasPrice: 100000000000  // default 100000000000(100 Shannon)
    }

You will also need to write migration scripts for truffle to deploy your contracts to the network - see here and here for more information on these.

Once you've written them, running truffle compile will build your contract files for deployment and truffle migrate --network <yourNetworkName> will connect to your geth instance and run the migrations in numerical order. As long as the relevant account is unlocked within geth you should see this reflected in your geth logs as transactions are broadcast during these deployments.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.