Most Popular
1500 questions
15
votes
1 answer
What fixed or float point math libraries are available in Solidity?
Solidity doesn't have fixed-point, floating-point, or double types. What solutions are there to handle the cases where we really have to represent numbers as percentages or fractions?
Paul Razvan Berg
- 17,902
- 6
- 73
- 143
15
votes
1 answer
how to get erc20 token balance using web3
I am still new with web3
How can I get balance of token?
On ropsten network, I have 100 LINK token.
Below is my code
const Web3 = require('web3')
const rpcURL = 'https://ropsten.infura.io/v3/xxxx'
const web3 = new Web3(rpcURL)
let tokenAddress =…
webmaster
- 153
- 1
- 1
- 6
15
votes
10 answers
Logarithm math operation in Solidity
what is the most efficient way to compute a logarithm in solidity? Is there a library that implements it or a built in function?
Doug King
- 458
- 1
- 3
- 8
15
votes
3 answers
Why do constant state variables get initialised every time?
I was working with constant variables in a contract
contract X{
uint constant var1=now;
uint var2=now;
function checkConstant() returns(uint,uint){
return (var1,var2);
}}
I was wondered each time I call checkConstant(..) , the return value…
Prashant Prabhakar Singh
- 8,026
- 5
- 40
- 79
15
votes
2 answers
Is it possible to call the constructor function of an existing contract?
In theory, a constructor is just a function like any other function, but only gets called once at construction time. Because the EVM doesn't know the notion of a constructor, in theory, a constructor can be called multiple times in EVM Opcode terms.…
Roland Kofler
- 11,638
- 3
- 44
- 83
15
votes
3 answers
Fatal: Failed to write genesis block: unsupported fork ordering: eip150Block not enabled, but eip155Block enabled at 0 genesis block
I am attempting to launch a private geth chain with the following command:
geth --datadir=./test-private-blockchain/ init genesis.json
I am receiving the following error:
Fatal: Failed to write genesis block: unsupported fork ordering: eip150Block…
Leon Africa
- 634
- 1
- 5
- 17
15
votes
1 answer
What is SSZ SimpleSerialize and why was it developed?
We were looking at the latest spec and it didn't have much background information or explanation on what SSZ is trying to achieve. What are the key goals of SSZ?
Examples of its serialization and Merkleization advantages would be very helpful as…
eth
- 85,679
- 53
- 285
- 406
15
votes
2 answers
How to conditionally send ethers to another account post-hard-fork to protect yourself from replay attacks
The DAO contract was attacked on 17th June 2016 where the attacker drained about USD 50 million worth of ethers using a recursive call vulnerability in The DAO contract code.
The attacker drained the stolen ethers into a few child DAOs and the…
BokkyPooBah
- 40,274
- 14
- 123
- 193
15
votes
2 answers
Working with structure arrays in solidity
I have the following contract code example:
contract C {
struct A {
uint256 a;
uint256 b;
}
struct B {
A ax;
uint256 c;
}
struct C {
string name;
B[] bs;
}
function…
Sebi
- 5,294
- 6
- 27
- 52
15
votes
1 answer
Type inaccessible dynamic type is not implicitly convertible
This code works:
contract C {
function Get() constant returns(bytes8[]) {
bytes8[] stuff;
return stuff;
}
function Copy() {
bytes8[] memory stuff = Get();
}
}
But when I try to call Get() in another way...
contract A {
A…
Raine Revere
- 3,600
- 2
- 23
- 34
15
votes
5 answers
ERC721: How to get the owned tokens of an address
There is a balanceOf function, but it only displays one uint (the token identifier)
I see most ERC721 tokens doing this so I am confused on how to view all owned tokens.
BlockchainBoy
- 345
- 1
- 4
- 10
15
votes
4 answers
How do I transfer balance to another address? w/o syncing with network
I have a single ethereum address that has ether in it from 2015 when I was playing around with Geth and the CLI. I have removed the blockchain and associated homebrew files from my computer. How can I transfer that balance from that ether account…
notaSRSbiz
- 151
- 1
- 3
15
votes
5 answers
How to prevent being blacklisted for running an ethereum client?
I'm running a dedicated server at one of the biggest hosters in Germany. This server serves the network with an Ethereum supernode, running parity 1.1.0 in archive pruning mode and allows up to 1024 peers to connect.
This morning I received an abuse…
q9f
- 32,913
- 47
- 156
- 395
15
votes
1 answer
How do I construct a call to another contract using inline assembly?
I would like to call a contract and deal with the return values manually using EVM assembly in Solidity. For example, this should simply add two numbers together.
contract Test1 {
function add(int a, int b) returns(int){ //Simply add the two…
Tjaden Hess
- 37,046
- 10
- 91
- 118
15
votes
1 answer
Trying to compile example code from pyethapp tutorial
I am trying to follow this example:
https://github.com/ethereum/pyethapp/wiki/The_Console
However, at the point where I should compile the code, I get an error:
In [34]: print c
contract NameReg{
event AddressRegistered(bytes32 indexed name,…
TMOTTM
- 1,953
- 2
- 14
- 23