Unable to open Ganache locally deployed contract in remix.ethereum - ethereum

I have successfully deployed a solidity contract locally with Ganache.
I would now like to interact with it via http://remix.ethereum.org/
In the remix editor,I have selected the "web3 provider" and connected to my local Ganache at "http://127.0.0.1:7545"
I have inserted my contract's Address in the "At address" section, but I continually connect to the default "Ballot" contract provided by remix.
Can anyone help me connect to my locally deployed contract?

Related

How to deploy hardhat contract to mainnet without ALCHEMY or INFURA?

How to deploy hardhat contract to mainnet without ALCHEMY or INFURA ?
Alchemy, Infura, and others, are services offering connection to nodes of the Ethereum network.
Contract deployment means that you broadcast a transaction with specific parameters (data field containing the compiled bytecode, to field empty). But you can only broadcast a transaction to the rest of the network from a node connected to the network.
So apart from using a third-party service, you can also run your own node. For example using the go-ethereum client software.
Then you'll be able to broadcast the transaction through this your own node, instead of a third-party one.

How to prefund a hardhat local node address

On spinning up a hardhat node locally, I get 10 addresses pre funded with 10k ETH. But none of these show up on metamask when I connect it to localhost:8545. As a result I'm not able to interact with a dapp deployed locally
Am I doing something wrong?
Usually, the back-end development project provides funded accounts which you can enter into Metamask, It's not like the Goerli or (now defunct) Rinkeby test networks where you can visit a site and have some ETH added to your test account because those test networks are hosted. You need to spin up a local project and have it provide funded accounts.
Such an example is Lesson 9: Hardhat Smart Contract Lottery in (Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript by Free Code Camp)
here is the code ...
https://github.com/PatrickAlphaC/hardhat-smartcontract-lottery-fcc
If you run that project it generates a number of addresses which you can connect to in Metamask.
MetaMask has no way of knowing which of your local accounts you want to import, or which are funded (prior to the import).
So you need to import the accounts to MetaMask manually using the private keys provided by Hardhat.

Cant access deployed contract with web3 after restarting local server

I made an app that interacts with a smart contract in the local ganache-cli server, with everything working fine, after restarting the server (and deploying againg the contracts) the app seems to not find the contracts. This is the error that I receive:
Error: UserController has not been deployed to detected network (network/artifact mismatch)
I've deployed the contracts and restarted the server multiple times but nothing seems to works, also MetaStack is able to interact with the server.
Try using the --reset --all flags which tends to resolve this issue.

Calling SmartContract deployed on Ropsten Test Net

I am new to smart contract development. I have a smart contract deployed on Ethereum blockchain Ropsten Test Net. I have smart contract address and ABI. I am not sure how to call functions of that smart contract from geth terminal.
Do i have to sync entire blockchain to call any smart contract functions deployed? I tried syncing but it never completes. It's stuck at last 100 blocks since a week. My ether balance is showing 0 when i connect to TestNet locally.
Is there anyway i can do this online? calling a deployed smart contract through Remix IDE or any other ?
Any help is highly appreciated.
My preferred way to do this is to install MetaMask and using that with Remix.

Remix Ethereum where goes the contract?

I don't understand where actually the smart contract goes, when I click on create under remix.ethereum.org. If I choose for example the Injected Web3, this should publish the contract to the ropsten test net, right? But how can I access the contract then? When I use metamask it injects me the right provider when I use web3.js, but how can I find this contract now, if I don't want to use the injected web3, but manually choose the provider address in web3.js? Can I access the smart contract this way?
Edit: I don't know what should be wrong about my question.I seriously find nothing about how how to connect to a smart contract for example in the ropsten test network without injected web3. Normally you do this in web3.js:
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
}
But if you don't have an injected web3, then you use the localhost. But I cannot connect then to the smart contract, because it does not know, in which net I actually published the smart contract, right?
Remix has 3 different environment options that can be used to deploy/test Solidity contracts: JavaScript VM, Injected Web3, and Web3 Provider. This option can be changed under the Environment drop down under the Run tab. (It looks like you've got this part...just documenting for completeness).
JavaScript VM: This is Remix's own internal sandbox. It does not connect to MainNet, TestNet, or any private network. It's an in-memory blockchain that can be used for simple testing and quick mining.
Injected Web3: This is the option to use for the browser plugin (MetaMask). Here, you are telling Remix to defer all control of the blockchain integration to the MetaMask plugin. At this point, MetaMask controls which network you are connecting to. In the plugin, you can connect to MainNet, Ropsten, Rinkeby, etc through Infura's node network. In this case, you're not running a node locally. MetaMask also has a localhost option where you can run your own node locally and MetaMask will send all transactions to it (this local network can be a private network using any node client or you can use a test blockchain like TestRPC).
Web3 Provider: This allows you to enter a URL in Remix to connect to the blockchain. The most common setup here is to be running a local node and connecting to it through it's IP/port. This is pretty much the same as using MetaMask's localhost option, but you're just cutting the plugin out of being the middleman. Just like option #2, the network your connected to depends on how you've configured your local node (it can be main, test, private, etc.).
So, "where your smart contract goes" depends on which of the configurations you have set up. Selecting Injected Web3 does not automatically mean your contract is being deployed to Ropsten. It depends on which network you have selected in the MetaMask plugin.
When using MetaMask through Remix, you need to use the plugin to select the appropriate account and confirm/reject transactions. Selecting the account is a bit confusing because Remix doesn't pick up all of the accounts imported into MetaMask. The Account dropdown will only have the account currently selected in MetaMask. In addition, if you change the account in MetaMask, you have to reload Remix for it to have that account selected in the dropdown. It does NOT automatically detect when the account has changed in MetaMask.
Once the account is properly selected (and assuming you're using an account that holds ether), you can now deploy your contract. Hit Create in Remix and then switch over to the plugin again. There, you should see a pending transaction waiting to approved. Select the transaction, then click Submit.
Transaction list:
Approve/Reject screen:
After submitting, it'll take a few seconds for the transaction to be mined. MetaMask will show when it's completed. That's it! To interact with the contract, you can initiate your transactions through Remix similar to the deployment steps above.