Truffle migrate is not deploying to Ganache - blockchain

I tried command truffle migrate --reset, but it is unable to connect to Ganche
here is the error:
This is the code inside truufle-config.js file:
And these are the RPC server details:

It seems there is a typo in your truffle-config.js: post instead of port.
Try this out:
networks: {
development: {
host: "127.0.0.1",
port: 9545,
network_id: "*"
}
},
Then:
Double check the settings on Ganache match with the ones on truffle-config.js
Check that Ganache is running.
And finally open a new terminal and run the following 2 commands in the same folder where the file truffle-config.js is hosted:
truffle console ––network development
migrate ––reset

Try this out:
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*",
}
},
Open the terminal and run the following command in the same folder where the file truffle-config.js is hosted:
truffle console ––network development

Related

Ganache Issue-Not showing the available networks

Iam trying to connect Ganache in mac, when i started Ganache ,its not showing the available accounts and open the server screen - unable to select the host name. It has only one option "hostname of the server 0.0.0.0 - All Interfaces."
I've tried
Restarting Ganache,
Restarting Computer,
Uninstalling from Applications and Reinstalling,
Ganache Downloaded Ganache from
https://trufflesuite.com/ganache/
FYI:i have installed truffle suite
Truffle v5.5.20 (core: 5.5.20)
Ganache v7.2.0
Solidity v0.5.16 (solc-js)
Node v16.15.1
Web3.js v1.7.4
Anyone has idea how resolve this issue.
Thanks in Advance
Laxmi
your truffle.config.js should have this minimum configuration to connect
module.exports = {
contracts_build_directory: "./public/contracts",
networks: {
development: {
// in hte truffle HOSTNAME down set the correct host. "0.0.0.0" should accept this
host: "127.0.0.1",
port: 7545,
network_id: "*",
},
},
compilers: {
solc: {
version: "0.8.13",
},
},
If ganache is running, when you start your truffle project it should automatically connect

Truffle configuration

truffle migrate --compile-all --reset --network ganache
Compiling your contracts...
Everything is up to date, there is nothing to compile.
Unknown network "ganache". See your Truffle configuration file for available networks.
By default you don't need to specify the --network, truffle will automatically connect to Ganache. On the other hand, if you want to have the name ganache configured as a network, you will have to modify your truffle-config.js file as follows:
networks: {
//...,
ganache: {
host: "127.0.0.1",
port: YOUR_GANACHE_PORT, // (default: 5777)
network_id: "YOUR_GANACHE_NETWORK_ID", // (default: *)
},
//...
}
Check this picture to see Ganache port and network_id

How can i deploy my contract on blockchain network?

I've being trying to create a basic smart contract and deploy it on blockchain using truffle,ganache.When i put this command on my truffle console it throws an error.I've looked for the solution but can't seem to understand where i am going wrong!Can anyone help me out?
This is my migrations 2nd file i.e 2_deploy_contracts.sol
var Election = artifacts.require("./Election.sol");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
This is my truffle-config.js
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// for more about customizing your Truffle configuration!
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*" // Match any network id
},
develop: {
port: 8545
}
}
};
Here's the error:
Uncaught:
Error: Election has not been deployed to detected network (network/artifact mismatch)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at Function.deployed (C:\Users\harshad\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\contract\constructorMethods.js:84:1)
at Object.checkNetworkArtifactMatch (C:\Users\harshad\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\utils\index.js:249:1)
I think the private network is not connected to your truffle.
Please check the following:
Private chain development tool (ex.Ganache) is running.
Check the private chain (Ganache) IP and RPC port numbers are the same as in the truffle-config.js file.
It will be the solution of this problem.

Running app with `eb local run` works, but cant actually connect to app

I've got a very straightforward Flask application running in a single docker container. When I run the app using eb local run it "works" in that the docker image is built, and I eventually see the log output from flask letting me know it's ready for requests. But when I actually attempt to query the running application, the requests fail immediately with errors saying 'the site cant be reached'. It seems like the app is running in the container, but somehow the ports aren't exposed correctly? Also, when I run it using docker run ... it works completely and I'm able to query the application.
Command I'm using:
eb local run --port 5000 --envvars APP_ENV=LOCAL
My Dockerrun.aws.json:
{
"AWSEBDockerrunVersion": "1",
"Ports": [
{
"ContainerPort": 5000,
"HostPort": 5000
}
]
}
My Dockerfile:
FROM python:3
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
ENTRYPOINT [ "python" ]
CMD [ "application.py" ]
My .elasticbeanstalk/config.yml:
branch-defaults:
python3:
environment: fs-service-prod
environment-defaults:
fs-service-prod:
branch: null
repository: null
global:
application_name: followspot-service
default_ec2_keyname: null
default_platform: arn:aws:elasticbeanstalk:us-east-1::platform/Docker running on
64bit Amazon Linux/2.12.11
default_region: us-east-1
include_git_submodules: true
instance_profile: null
platform_name: null
platform_version: null
profile: null
sc: git
workspace_type: Application
Output of eb local status:
Platform: 64bit Amazon Linux 2018.03 v2.12.11 running Docker 18.06.1-ce
Container name: 6739a687fa2d18f1c683926f024c88bed9f5c6c7
Container ip: 127.0.0.1
Container running: True
Exposed host port(s): 5000
Full local URL(s): 127.0.0.1:5000
Thanks so much for any help you can give me and let me know if there's a good way to go about getting more helpful info.
Figured it out! Turns out this was an issue with how I was starting my Flask app. Because flask by default runs on 127.0.0.1 and Docker by default runs tries to connect to 0.0.0.0, I needed to change how the app is started in my Dockerfile.
Instead of:
ENTRYPOINT [ "python" ]
CMD [ "application.py" ]
I had to change it to:
ENV FLASK_APP application.py
ENTRYPOINT ["python", "-m", "flask", "run", "--host=0.0.0.0"]
Then everything worked as expected.

Can not connect to Truffle or testrpc with Ganache GUI

I have Ganache GUI from appx from official website on my Windows 10. When I run Truffle or testrpc network in my console (WSL) and try to connect there from Ganache GUI in settings, I get error message next to the textbox with a port:
The port is used by another application; please change it
the port is from Truffle or testrpc. How can I connect there? Thank you.
Ganache UI runs an instance of Ganache CLI (i.e. simulated Ethereum instance previously called TestRPC). If you already have a console window open with an application on port 9545 then Ganache UI cannot start a new instance on that same port.
I add the following to my .zshrc or .bashrc file
# Get WSL Host IP
export WSL_HOST_IP="$(awk '/nameserver/ { print $2 }' /etc/resolv.conf)"
This allows me to surface my host ip, so commands in WSL2 can reach the localhost.
Now create a workspace in Ganache GUI and under the server HOSTNAME settings choose "0.0.0.0 - All Interfaces".
In your truffle project edit the truffle-config.js file and set your network development block to this:
development: {
host: process.env.WSL_HOST_IP,
port: 7545,
network_id: "*" // Match any network id
}
Now when you run truffle migrate, it should connect to the Ganache GUI.
These are the steps that worked for me:
Start ganache-ui
Configure truffle's network in truffle-config.js:
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 7545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
...
Run truffle console (NOT truffle develop)