I have created a sample smart contract in the online solidity compiler called Remix and I have also created a private blockchain. Then I also have an ethereum wallet running on this private test network. Can anyone tell me how can I use this smart contract in the ethereum wallet?
There are 2 ways.
- Deploy the contract using ethereum-wallet and using this directly.
- Deploy the contract using remix and add the deployed contract to ethereum-wallet.
Let's see each one by one:
Deploying using Ethereum wallet (or Mist)
- Start privet blockchain and run ethereum-wallet(or Mist). Make sure Mist is connected to your private network and not the public network.
- Go to contracts tab in Mist.
- Click on deploy new contract.
- Paste the contract code in
SOLIDITY CONTRACT SOURCE CODEtab.
- Choose the owner account from which you want to deploy the contract.If you have multiple contracts, choose the contract you want to deploy. (You may need to specify constructor arguments if your contracts have them).
- Choose the account from which you want to deploy the contract under thr
- Click on deploy.
- Make sure miner is running. (you can type
geth consoleto start mining and
miner.stop()to stop mining.
- Once the contract is deployed, you can access the contract in
COntractstab of Mist
Deploying using Remix
First, connect your remix compiler to your private network.
runtab of remix and under
Web3 Provider Endpointenter Rpc address of your node. (like http://127.0.0.1:8015)
Once your node is connected, you can choose the account from the
accountstab and deploy the contract. (I guess you have already done this).
Remember you have to run miner if it's not already running to mine your transaction.
Once the contract is deployed, copy the address of smart contract and abi.
Open your ethereum-wallet, which must also be connected to same private blockchain to which remix was connected.
contractstab and click on
Enter the name of contract and the address and abi you just copied. And your contract will be visible under
make sure your private network is running. Then simply open a terminal and do
$ ethereumwallet --rpc path/to/geth.ipc
for example for me
$ ethereumwallet --rpc privateNetworks/geth_PoA/node1/geth.ipc
if you have rpc allowed then
$ ethereumwallet --rpc "http://localhost:8545"
should also work (update the rpc port to your config). From there, use the ehereum wallet UI for deploying contracts. You'll need the bytecode and abi of your smart contract. To get them, do
$ solcjs --abi --bin yourContract.sol
and just copy paste the content in the ethereum wallet under "create contract".
The process is exactly the same for mist.