3

You could put in useEffect a listenEvent like below: useEffect(() => { async function listenMMAccount() { window.ethereum.on("accountsChanged", async function() { // Time to reload your interface with accounts[0]! accounts = await web3.eth.getAccounts(); // accounts = await web3.eth.getAccounts(); console.log(...


2

You cannot get the private key from web3.eth.getAccounts() directly, but there's a few workarounds to do this with ganache: Specify a mnemonic phrase with the -m option, e.g. ganache-cli -m "stereo consider quality wild fat farm symptom bundle laundry side one lemon", this will derive private keys from the mnemonic phrase (with the derivation path ...


2

Self-answering my own question 4 years later: Yes! I wrote an Secp256k1 implementation in Crystal: github.com/q9f/secp256k1.cr In that process, I implemented both key management for Bitcoin and Ethereum. The same keypair can be used to retrieve Bitcoin and Ethereum formatted addresses: generate a compressed bitcoin mainnet address: key = Secp256k1::...


2

Account information is the local filesystem on a JSON file. You can move this file between different geth installations if you want to import/export account between different installations.


2

There's currently no way to unlock from the Remix UI in either the Quorum plugin or regular Remix. But it would probably be a good feature to add to the plugin. The alternative right now is to temporarily unlock it and deploy (you can pass a second parameter to unlockAccount to tell it exactly how long to keep unlocked). You can also go to the compilation ...


1

Truffle v5 uses web3 v1.x which is fully async. For all calls that interact with the blockchain use await in front. truffle(develop)> accounts = await web3.eth.getAccounts() undefined truffle(develop)> accounts [ '0xe2aa116DDD9A562895A7DeFa3eb8049a28Ce04B0', '0x28Da3F02B460F303FD161F6f3406cE9070aF8710', '0x63d666a8421a45119A63787400dD6bdF0C91bB57'...


1

First of all, you can always specify the account with which you want to interact with the contract, using the from keyword, e.g., instance.someFunction({from: accounts[0]}). Second, you can edit the default address in the truffle-config.js file at networks.advanced.from, which equals to accounts[0] per default.


1

Encapsulate it all with: contract("MyContract", function(accounts) { ... });


1

Now you can use await to simplify code: let accounts = await web3.eth.getAccounts()


1

EOAs and Contract accounts are indistinguishable by looking at their addresses. Contract accounts are the only type of account with associated bytecode. Private keys are generated only for EOAs while CAs are controlled by the contract.


1

Using ganache-cli, you can provide a mnemonic using the flag below, in order to produce the same pre-funded addresses and public keys every time you start ganache. The accounts flag just defines the number of accounts that you will create. -m or --mnemonic: Use a bip39 mnemonic phrase for generating a PRNG seed, which is in turn used for hierarchical ...


1

Yes it is secure. If you don't pass entropy to it, it will use randomhex, see Web3 docs. That uses the secure crypto.randomBytes function which is pretty secure. It's just a wrapper around OpenSSL's RAND_bytes().


1

I think you are trying to get the accounts of ganache using JavaScript in truffle console I advise you to write the following snippet Web3.eth.getAccounts(function(err,res){accounts=res}); and then you can access the list of accounts in truffle console using the following command accounts


1

Correct. You need to pay transaction fee for each transaction and one transaction can only tranfer assets from one account. Or if the origin account is actually a smart contract then it can transfer to multiple accounts in the same transaction. Ethereum is not meant for such use - if you need similar (UTXO) functionality you should write a smart contract ...


1

If your MetaMask is open, it means you don't need to get permission anymore. however new MetaMask can be found in window.ethereum not in window.web3. only legacy (outdated) MetaMask users still have window.web3. Try this Code import Web3 from 'web3'; let w3 if(typeof window !== 'undefined' && typeof window.ethereum !== 'undefined'){ //getting ...


1

You can npm install keythereum, and then run the following NodeJS script: const fs = require("fs"); const keythereum = require("keythereum"); const KEYSTORE = process.argv[2]; const PASSWORD = process.argv[3]; for (const fileName of fs.readdirSync(KEYSTORE)) { const keyObject = JSON.parse(fs.readFileSync(KEYSTORE + "/" + fileName, "utf8")); const ...


1

If the transactions are created close to each other they are possibly valid transactions. If one transactions has already been processed (mined) and the wallet knows about this then the wallet refuses to even send the second transaction. If both of the transactions are accepted by the wallet they are added to an abstract transaction pool which is basically ...


1

The difference is what RPC method is being called under the hood. From the docs: web3.persal.getAccounts returns a list of accounts the node controls by using the provider and calling the RPC method personal_listAccounts. The results are the same as web3.eth.getAccounts() except that calls the RPC method eth_accounts.


1

You're trying to apply a model that is appropriate for Bitcoin mainly due to its limitations. It will be an awkward strategy for Ethereum that overlooks it's strengths. Bitcoin: Not especially programmable, but easy to sweep funds from multiple accounts. Ethereum: Especially programmable, but not so easy to sweep funds from multiple accounts. Ethereum ...


Only top voted, non community-wiki answers of a minimum length are eligible