Most Popular
1500 questions
31
votes
3 answers
What is the difference between the constant and immutable keywords in Solidity?
What is the difference between the constant and immutable keywords in Solidity and how do I use them?
Shane Fontaine
- 18,036
- 20
- 54
- 82
31
votes
1 answer
How does the delegatecall method work to call to another contract's method?
I'm trying to figure out how to use the delegatecall method on a contract address in a contract to call a function in a separate contract.
I know Libraries are the higher level interface to use but I want to understand the lower level actions and…
aDude
- 313
- 1
- 3
- 4
31
votes
3 answers
What is calldata?
What is calldata? I learned that there are three types of memories:
Storage
Memory
Stack
In the Ethereum docs, it says that the function parameters are of type memory by default.
However, I've also read an article which said that function…
Sheikh
- 445
- 1
- 4
- 9
31
votes
1 answer
What is and how to calculate 'cumulative gas used'?
When I see transactions in Etherscan (e.g., 0x7eb9a7454f9cd2f39a7ea7c6212833673165b35f352127ffb337df866897eb73), I see the field Cumulative Gas Used which isn't present in web3 response.
In general, it is equal to Gas Used but I wonder if it could…
Paul Exchange
- 2,723
- 3
- 21
- 26
31
votes
7 answers
how to compare strings in solidity?
pragma solidity ^0.4.11;
contract test2
{
address creater;
string username;
string password;
function testusernamepassword(string username,string password) returns (bool)
{
if (username == "deepak" && password ==…
Deepak Baberwal
- 389
- 1
- 5
- 5
31
votes
2 answers
Why are there no leading zeroes in ethereum block hash?
The block hash has to be below certain difficulty, right? In bitcoin this means, that there are many leading zeroes in hash value, eg. for bitcoin block #402329 hash is 000000000000000006efd706f4467e2d7ed6f0fed757ca7d59e2cc8c81a2d9e3.
But for the…
Matias
- 1,109
- 1
- 10
- 16
31
votes
5 answers
Run a single hardhat test
I have a test file in hardhat like so:
const { expect } = require("chai");
describe("contract tests", function () {
it("does function one", async function () {
expect(await someContract.someFunc()).to.equal(something);
});
it("does…
Patrick Collins
- 11,186
- 5
- 44
- 97
30
votes
4 answers
Calling function from deployed contract
I want to know how to instantiate an existing contract deployed on the blockchain using its address.
e.g:
contract A {
function f1()
{}
}
A is deployed on the blockchain, and in contract B I want to call the function f1() and get its…
Sig Touri
- 1,090
- 2
- 14
- 23
30
votes
5 answers
How can I perform float type division in solidity?
How can I achieve proper division of two integers in solidity?
Suppose I perform : 3/2 the solution provided is 1 and not 1.5
please help.
Vaibhav Tiwari
- 491
- 1
- 5
- 7
30
votes
2 answers
Is there a maximum number of entries for a mapping?
In many contracts, notably voting, there is a mapping of the kind mapping(address => bool) voted;
How many voters can be registered in that way? is there a size limit? will the contract need more and more gas for each query until it reaches the…
Micha Roon
- 2,203
- 21
- 36
30
votes
1 answer
How can I verify a cryptographic signature that was produced by an Ethereum address key pair
If I have a cryptographic signature from an Ethereum address key pair, how can I verify that signature?
Piper Merriam
- 3,592
- 3
- 22
- 34
30
votes
7 answers
How can I detect change in account in Metamask?
When a user changes to a different account in metamask, is there a way to detect it asynchronously in code?
I currently use
this.web3.eth.getAccounts((err, accs) => {
this.account = accs[0];
});
but when the account is changed, it still…
bbusdriver
- 1,144
- 2
- 18
- 33
30
votes
3 answers
If someone found a private key to 0x0, would they be able to access all the tokens (over one billion dollars worth) stored there?
The 0x0 address in Ethereum has a lot of token stored in it that have been burnt in the past. However, it appears they burning is the same as sending to 0x0. In that case, could all of those burnt tokens be recovered if someone had access to the…
Elliot A.
- 403
- 1
- 4
- 6
30
votes
4 answers
Does every node execute the contract code for each transaction?
This question was asked on Reddit a while ago:
When a node sends a transaction to the network and has the receiver as a contract, does every node execute the contract bytecode with the inputs to confirm the hash? Or does the first node receiving…
J-B
- 8,941
- 16
- 46
- 77
30
votes
3 answers
Is Ethereum secure against an attack by quantum computers?
Does Ethereum implement Post-quantum cryptography? Or will the network break once a malicious actor gains control of an effective quantum computer?
Shelvacu
- 1,405
- 1
- 12
- 22