Steven V
  • Member for 3 years, 7 months
  • Last seen this week
How can I get a private key from a mnemonic phrase?
Accepted answer
11 votes

Here are two options: Using ethers.js - the example below uses a mnemonic ethers wallet documentation const ethers = require('ethers'); let mnemonic = "YOUR MNEMONIC"; let mnemonicWallet = ...

View answer
myContract.events.MyEvent() vs web3.eth.subscribe('logs', ...);
7 votes

They are both subscriptions to events, but filtered a little differently. myContract.events.MyEvent() will only return MyEvent events from the specific contract address that you used to create the ...

View answer
Why does a miner still pay gas for a reverted transaction?
6 votes

A reverted transaction generally means that the logic of the smart contract being used failed or there's not enough gas to complete the transaction. The transaction was still executed by the miner, ...

View answer
How to generate a unique random number in web3.js?
4 votes

There is a util that can create "cryptographically strong pseudo-random HEX strings from a given byte size." You could then convert this to a number. web3.utils.randomHex(size) --> documentation Per ...

View answer
Change default wallet address in ethers.js
Accepted answer
4 votes

You can use an HDNode which is defined as: A Hierarchical Deterministic Wallet represents a large tree of private keys which can reliably be reproduced from an initial seed. Each node in the ...

View answer
In a clique consensus private network, what happens when a sealer (signer) stops mining
4 votes

Clique requires int(N/2+1) sealers (where N is the number of sealers defined in the genesis file — in extraData field) to be online in order to run. thx to Ivica Aracic for pointing out that ...

View answer
what happen if my node synced with uncle block?
2 votes

You are correct to think the latest block or blocks that you’ve received could be orphaned. This is the reason you don’t immediately rely on data in the most recent blocks. You will generally want to ...

View answer
How does metamask know a contract is for ropsten or for main network?
2 votes

Metamask doesn't know that your contract only exists in Ropsten. When you log into metamask, you select the network that you want to work with in the dropdown in the picture below. This is the ...

View answer
Why does not Ethereum allow removing all entries from a mapping, like clear() in Python
2 votes

Ethereum / solidity does not allow the clearing of mappings because mappings do not inherently keep track of the keys. A user would be required to provide the key for each used spot in the mapping to ...

View answer
bootstrap node vs cmd/bootnode
Accepted answer
2 votes

The section Setting Up Networking here describes how to run a bootstrap node. It looks like you just need to provide the flag --nat with the IP address of the computer/server running the code when ...

View answer
How to encode an object with ABIEncoder V2?
2 votes

See the example below Warning from Remix: Experimental features are turned on. Do not use experimental features on live deployments. pragma solidity ^0.5.12; // Enable the ABI v2 Coder pragma ...

View answer
How to get a nested map value from web3.js?
Accepted answer
2 votes

consider adding the following function to your smart contract: function getSpentLimit(address a, address b) public view returns (uint256) { return spentLimit[a][b]; } then you can call this ...

View answer
Send funds locally
2 votes

You can reference the web3.js docs around sending a transaction here: https://web3js.readthedocs.io/en/v1.2.4/web3-eth.html#sendtransaction the example looks like: // using the promise web3.eth....

View answer
Build Java based application which act as front end and ethereum smart contract as back end
2 votes

You can use java to interact with your smart contract using web3j. https://web3j.readthedocs.io/en/latest/smart_contracts.html You can still use solidity and truffle for the smart contract ...

View answer
Estimate Gas cost for a function call in solidity (on-chain)
1 votes

As far as I know - you can't actually estimate the gas from solidity. Two Related pieces of functionality that might be helpful: You can potentially use gasLeft(); Global Vars You can call this ...

View answer
Set block size and block number
Accepted answer
1 votes

If you want to change parameters of the eth network, you can run ganache locally on your computer. This is an Ethereum simulator where you can change the parameters of the network. For example - this ...

View answer
Reproducing a Ganache Server across multiple computers
Accepted answer
1 votes

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 ...

View answer
What's the purpose of the following code in the program?
1 votes

Payment memory payment = Payment(msg.value, now);//this stores ^ The comment //this stores is incorrect. This line just creates an instance of the payment struct and does not save it. memory ...

View answer
How do I activate HTTP JSON-RPC on a Geth node?
1 votes

Instead of admin.startRPC(addr, port), when you start your node (if you are using geth) you can use the rpc flag geth --rpc - this defaults to localhost:8545 You can also define your own address ...

View answer
Why do we use `serialize` function of `ethereumjs-tx` package before broadcasting a transaction
Accepted answer
1 votes

The serialize function is used to convert the javascript transaction object into an RLP encoding of the transaction. The RLP encoding processes use a standard method to encodes structures/objects into ...

View answer
ABI and Bytecode stored inside Contract
1 votes

Once your contract is deployed, you can use assembly code within solidity to access your byte code as seen in this example below. The benefit of this vs just saving a parameter is that you are ...

View answer
Simulate how a transaction will affect state before it is mined
Accepted answer
1 votes

You can interact directly with the ganache-core library: github Below is a test with using the infura API. This also works with a local node. const ganache = require("ganache-core"); const Web3 = ...

View answer
Cant Retrieve the values of Structure fields (i.e. text boxes) through Remix IDE
Accepted answer
1 votes

The increment people count is added before adding the person to the mapping. So nothing is added to the people[ 1 ] spot in the mapping. As is, the first spot in the mapping that gets filled is people[...

View answer
Using NFT paired to credentials for identity verification
1 votes

Rather than using credentials or an NFT, maybe just have the user interact with your application through their ethereum address / wallet. Any changes to this address's account in your application ...

View answer
How can i add smart contract to metamask?
1 votes

Below is an example using react, ethers, and metamask to interact with an erc20 contract on ropesten. When the page loads it triggers the following transaction request in MetaMask to transfer the ...

View answer
Making contract compatible with newer solidity compiler
Accepted answer
1 votes

The code below compiles with ^0.5.16. There were a few updates needed. 1 - constant is no longer used. You need to use either view or pure more info here I made all view because they read the state. ...

View answer
Remix IDE: How to debug a contract having a function with a argument & for Loop
1 votes

As @Chan-Ho Suh suggested in the comment you are looking through the debug of the transaction of the contract being deployed. As in your initial question, there is no constructor, there is nothing to ...

View answer
Store and Display the Json file in Blockchain
1 votes

There are lots of different ways you could manage writing this data to ethereum. Depending on how big your JSON files are / how many json files you'll need to publish, this is a potential solution. ...

View answer
Multiple GasLimits on my Private Ethereum network?
Accepted answer
1 votes

The gas limit can change overtime based on the targetgaslimit set by miners (this is geth terminology). The gas limit is capped with an upper and lower bound and can only be changed so much with each ...

View answer
what kind of Hardware required for run geth private chain for ethereum on windows?
1 votes

If you only need this for development purposes, you can likely just use your laptop / desktop. Here's a tutorial for setting up your own private network creating two local nodes on the same computer. ...

View answer