Badr Bellaj
Moderator
  • Member for 5 years, 8 months
  • Last seen this week
How to detect if on mainnet or testnet?
Accepted answer
42 votes

Prior to Web 1.0 you can use web3.version.getNetwork as following: web3.version.getNetwork((err, netId) => { switch (netId) { case "1": console.log('This is mainnet') break ...

View answer
How to detect if an address is a contract?
Accepted answer
39 votes

you can use getcode function. if the address is representing an External Owned Account you will get 0x as response otherwise you will get the contract's bytecodeode. for example : web3.eth.getCode("...

View answer
What is the difference between a pending transaction and a queued transaction in the geth mempool?
Accepted answer
24 votes

Look at the answer in What is the max size of transactions can clients like geth keep in txpool? What is the difference between a pending transaction and a queued transaction? Pending ...

View answer
What was the reason to invent the EVM?
Accepted answer
22 votes

So the important point in your question is why a new VM and not a java VM. ok let's choose a Java VM instead, what do we get? : 1- complex and voluminous Bytecode => how to store it, in the ...

View answer
Power operations in solidity
Accepted answer
21 votes

you need only to use **. the following function calulate A to the power of B. function power(uint256 A, uint256 B) public returns (uint256){ return A**B; }

View answer
understanding mload assembly function
Accepted answer
19 votes

mload(0xAB) Loads the word (32byte) located at the memory address 0xAB. e.g mload(0x60) loads the word located at 0x60 memory address. let's code to understand more : function f () { ...

View answer
Calling function from deployed contract
Accepted answer
17 votes

If the deployed contract doesn’t adhere to the ABI, but you know the contract signature (name and argument types) You could use : contract_address.call(bytes4(sha3("function_name(types)")),...

View answer
How to convert a string to bytes32?
17 votes

string is not equal to bytes32 but it is equal to bytes, because its length is dynamic. so you could use a casting bytes B=bytes(S); //S string E.g contract string_test { function ...

View answer
Insufficient funds for gas * price + value
17 votes

It seems to be a bug in geth, try the solution presented here : https://github.com/ethereum/go-ethereum/issues/2173 they assume that the solution is : Convert all values to hex (with bc if you use ...

View answer
How to get ether on public testnet?
16 votes

you can get ethers on the testnet simply by using Metamask plugin. here's how: You need beforehand install metamask plugin from here, then follow the steps shown in the following picture : 1-press ...

View answer
Where is the state data stored?
16 votes

Technically the states are assembled into a state tree (patricia-tree) linked to the account (balance in case of EAOs and balance and storage in case of contract's account) and to the blocks (figures ...

View answer
Error: VM Exception while processing transaction: out of gas
Accepted answer
15 votes

First check your account balance : balance = web3.eth.getBalance(someAddress); then try to specify the gaslimit contractInstance.createProposal("ADHD", "Foo", 2, {from: web3.eth.accounts[1], gas:...

View answer
What are the Ethereum disk space needs?
15 votes

I've stumbled upon the links bellow : 1- provides an online chart which presents the Ethereum's blockchain current size evolution alongside the Bitcoin blockchain's size. http://bc.daniel.net.nz/ ...

View answer
How to schedule a transaction?
Accepted answer
15 votes

You could run the following function : function f( blocknumber, to_address, value_) { var filter = web3.eth.filter('latest').watch(function(err, blockHash) { var target=blocknumber; if(web3....

View answer
Solidity: Is there a way to get the timestamp of a transaction that executed?
Accepted answer
15 votes

A Transaction doesn't have a timestamp. However, Every block provides a timestamp(when it was collected), but if the time is critical for you don't refer to this timestamp because a miner could modify ...

View answer
What is an ABI and why is it needed to interact with contracts?
14 votes

think of "ABI" as an "API" at a low level. Think of it as the compiled version of an API (or as an API on the low level). As you know the contracts are stored as bytecodes in a binary format into ...

View answer
get the return of a function with multiple returns
Accepted answer
14 votes

You can use double return in a function. To get the returned value in your example use: uint256 c; uint256 d; (c,d) = f();

View answer
What is the difference between m/44'/60'/0'/0 and m/44'/60'/0'?
Accepted answer
14 votes

Jaxx,MEtamask,...etc uses the BIP44 derivation. from the BIP44 specification, the HD derivation path is defined as : m / purpose' / coin_type' / account' / change / address_index But some wallets (...

View answer
What does the indexed keyword do?
13 votes

The indexed keyword helps you to filter the logs to find the wanted data. thus you can search for specific items instead getting all the logs. in general : event <Identifier>(<parameters&...

View answer
Debugging Ethereum Contract by printing the values
Accepted answer
13 votes

you could use events to debug(log) the desired variable.Please read the official documentation to get more details. e.g : pragma solidity ^0.4.0; contract test { event test_value(...

View answer
Bad Jump Destination error
Accepted answer
12 votes

While you are using Solidity 0.4 you should define your payable function. if your contract will receive Etheres define in your code payable fallback: function() payable {} if you want any functions ...

View answer
How can I debug a smart contract?
11 votes

to debug a contract you could use the solidity browser the debugger provides you the ability to debug any transaction (creation or call) step by step and to visualize the memory/storage space. it ...

View answer
Is block.timestamp safe for longer time periods?
11 votes

The miner could cheat in the timestamp by a tolerance of 900 seconds. so if you check outside this intervall you are safe.

View answer
Problem with Truffle Console: Cannot read property 'call' of undefined
11 votes

you could also use : HelloWorld.deployed().then(helloworld=> console.log(helloworld.balance.call())) or HelloWorld.deployed().then(function(instance){helloworld=instance}) then helloworld....

View answer
what is block.timestamp
11 votes

As per the documentation you will find timestamp of the current block in seconds since the epoch so you have a single timestamp (when it is created) per block therefore time1=time2 read more ...

View answer
What is knownStates?
Accepted answer
11 votes

during fast sync, web3.eth.syncing downloads the state trie. knownStates is the number of trie nodes that the sync algo knows about pulledStates is the number it already downloaded there's no way to ...

View answer
How can the web3 library be imported in a web application?
Accepted answer
10 votes

by web application you mean HTML/.. download web3js form github repo. you could load it as normal js file using <script src="web3js_path"></script> e.g <script type="text/...

View answer
To which remote ethereum nodes does Metamask plugin send signed transactions? and are they exposed to denial of service attacks?
10 votes

more concretely metamask is connected to those infura's nodes : const MAINET_RPC_URL = 'https://mainnet.infura.io/metamask' const ROPSTEN_RPC_URL = 'https://ropsten.infura.io/metamask' const ...

View answer
What's the difference between node and peer?
9 votes

In my opinion : a network node is a connection point(endpoint) that can receive, create, store or send data along distributed network routes. In Ethereum it could be full or Lightweight. in case of ...

View answer
Questions about SimpleAuction contract example
Accepted answer
9 votes

Q1 : this a protection measure against call depth stack attack. a well known attack against the smart contracts in which the attacker (which is a malicious contract) exploits the fact that the calls ...

View answer
1
2 3 4 5
17