How do I connect web3JS to my locally hosted truffle session. I use async functions too regularly and I need some help.
I think you can share your code here if possible, so we can see what is wrong.
This is not a code issue as much as its a question of how to connect web3js to truffle I know how to do it in remix but I am new to truffle
You can have a try like this:
// truffle-config.js
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 7545, // Default Ganache port
network_id: "*" // Match any network id
}
}
};
And then use the web3.js
const Web3 = require('web3');
// Connect to Ganache
const web3 = new Web3('http://127.0.0.1:7545');
1 Like
Thanks! that helped alot!
1 Like
Truffle is dead, use Hardhat or Foundry as smart contracts development framework.
You can also use Hardhat to start a local network for testing, good luck.