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.