15

I need my accounts in Metamask to match my local machine so I can deploy from the machine (using truffle), and test in a browser. How can I either:

  1. Upload my local geth accounts to Metamask
  2. Bring my Metamask keys into geth

Truffle seems to deploy from your 'eth.coinbase' account whatever that may be, so most importantly I need that one to match Metamask.

  • 1
    How do you find your private key? I created an account with Truffle on testnet but I don't know how to view my private key – nickjm Jul 8 '17 at 15:15
14

You can now import single/"loose"(as we call) keys into MetaMask if you click the menu in the top right corner. It will drop down with the option "Import account", you can click that and it will take you to a view where it will ask you to import your private key or json file.

12

Edit: the following info is outdated. It still works, but see the verified answer to import directly.

Currently I don't believe you can import into Metamask, so I did it the other way around. Here is how:

1) Go to the account in Metamask and Export the account you want. This will give you the private key.

2) Create a file on your desktop called boring_tax_stuff.txt and paste your private key (make sure not to add any spaces or anything. You may have to remove the "0x").

3)From a terminal type geth account import ~/Desktop/boring_tax_stuff.txt or geth --testnet account import ~/Desktop/boring_tax_stuff.txt if you want to add them to your Morden wallet (they are separate wallets).

4)You should see it immediately in geth console by typing web3.eth.accounts

Unfortunately your primary account or "coinbase" will not change. To change this, I just changed the timestamp in the filename of the accounts. So:

5)Navigate to ~/Library/Ethereum/keystore or ~/Library/Ethereum/testnet/keystore and change the dates so that the account you desire to be 'coinbase' is earliest.

6)Change the contents of boring_tax_stuff.txt, save it, then delete it.

You can restart geth and type web3.eth.coinbase to verify everything worked!

  • If I'm not mistaken, when importing the account, the --testnet flag refers to the Ropsten network. For the Rinkeby network, the flag is --rinkeby. – Thalis K. Jul 15 '18 at 21:56
4

Truffle lets you deploy with the account you want. For this you need to edit the truffle.js file and provide a value for rpc.from. this being the address you wish to deploy from. If you dont use testrpc you will have to ensure that this account is unlocked before you deploy/migrate from truffle.

  • how do you unlock the account? i have a test account in metamask with some test ether (on rinkeby) and i want to use it with truffle migrate. how does that work? – Julien Jan 8 '18 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.