How to deploy smart contracts to the POA network with truffle


#1

Hello everyone I am currently struggeling to deploy my dapp to the poa testnet. (https://sokol.poa.network)

I have a working dapp that I deployed to my local ethereum testnet using truffle compile and truffle migrate.

Now I tried to run the dapp on the poa network instead.
my truffle.js file likes like this:

module.exports = {
  networks: {
    development: {
      host: "https://sokol.poa.network",
      port: 8545,
      network_id: "*" // Match any network id
    }
  }
};

When I try to run the command truffle migrate --reset (to deploy the smart contracts to the poa network I get the following error:
Could not connect to your Ethereum client. Please check that your Ethereum client:
- is running
- is accepting RPC connections (i.e., “–rpc” option is used in geth)
- is accessible over the network
- is properly configured in your Truffle configuration file (truffle.js)

Just as suggested in the docs I installed parity and I can open and interact with the parity interface normally, I even run parity with the insecure flag to enable rpc calls:
parity --warp --config dev-insecure --chain spec.json --reserved-peers bootnodes.txt ui

Howewer it seems like truffle and parity do not communicate well with each other when I try to deploy my contract.
Is there a way to run the poa network with geth? Geth and truffle have proven to work well with each other.

Is there a step by step guide somewhere about how to deploy a smart contract with truffle to the poa network? I am aware that I can just deploy the smart contract with parity but since my development workflow includes truffle it would be great if there would be a solution to this.

Thank you very much in advance for your help!


#2

hello @honigdachs I think you need to make one small change and you will be good to go to deploy your DApp on the Sokol Test Network! After testing you will be able to use these same commands with a minor change to deploy on POA Core. Please modify your truffle.js file wth this single change:
module.exports = {
networks: {
development: {
host: “https://sokol.poa.network”,
port: 443, // change this from the sample default config of port 8545
network_id: “*” // Match any network id
}
}
};

The RPC port for https://sokol.poa.network is port 443. That should fix your issue and your DApp will deploy to Sokol Test network! After testing on Sokol when you are ready to deploy to the POA Core network, you will simply substitute https://core.poa.network for https://sokol.poa.network .

While it is convenient to run a local parity node for building and testing in a lab environment, it is not strictly necessary for deploying to Sokol or any blockchain, since when host: “https://sokol.poa.network” is set in truffle config you are communicating directly with the Sokol network and not a local server.

Depending on how you may be running a local Parity node, you shouldn’t need set the dev-insecure flag. Remember if you are running a local Parity node you need to choose which network your local node will participate with, for example Sokol, POA Core, Ethereum, etc. That shouldn’t matter for this discussion. Please post a link here so we in the community can take a look and help test. Good luck - looking forward to your feedback!


#3

Thank you very much for your help @1proof! Unfortunately I am after applying your changes I am still running into the same error I am still getting the errror:
Could not connect to your Ethereum client. Please check that your Ethereum client:

  • is running

  • is accepting RPC connections (i.e., “–rpc” option is used in geth)

  • is accessible over the network

  • is properly configured in your Truffle configuration file (truffle.js)

    module.exports = {
    networks: {
    sokol: {
    host: “https://sokol.poa.network”,
    port: 443,
    network_id: “*” // Match any network id
    }
    }
    };

the command I ran was:
truffle migrate --network sokol
I tried running it both with and without running my local parity wallet.


#4

You can specifically identify Sokol:

network_id: “77” // Match Sokol Network only

truffle migrate --reset should work - you want to start clean.

Based on your config you are not (or should not be) trying to access the Sokol network on your local Parity node; it should not come in to play. I’m not sure of your local setup or dev environment. Please try specifying the network and reporting back with your results. Are you able to connect from your workstation to the Sokol RPC Server at https://sokol.poa.network via Metamask? Here are instructions from the POA Network Wiki:
https://github.com/poanetwork/wiki/wiki/POA-Network-on-MetaMask


#5

Specifically the magic that’s missing is you need to pay for gas network when deploying contracts - and from a funded account.

So , get seeds words (MNEMONIC) from wallet that has a funded account.

Then use
var HDWalletProvider = require(“truffle-hdwallet-provider”);

I created a gist for that you can use.

Just set environment variable locally when running to your mnemonic