Most Popular

1500 questions
22
votes
2 answers

What are effective techniques to encrypt/decrypt data stored in a smart contract?

Rather than sending and storing plain text in a smart contract, the use case objective is to encrypt first and then subsequently access the data and decrypt at the point of use. What is the most effective and efficient way of achieving this data…
Alan Wunsche
  • 1,655
  • 2
  • 16
  • 19
22
votes
2 answers

Problem with Truffle Console: Cannot read property 'call' of undefined

I´m having problem with the basic HelloWorld example coded in Solidity and managed with truffle with testrpc. pragma solidity ^0.4.2; contract HelloWorld { uint public balance; function HelloWorld() { balance = 1000; } } > …
hejnal
  • 263
  • 1
  • 3
  • 6
22
votes
3 answers

How does the Ethereum ETH accounting system work and prevent double-spends?

In Bitcoin, the BTC accounting system is based on UTXOs (Unspent Transaction Outputs), which prevents the same BTC from being spent multiple times. I heard that Ethereum has a simpler account balance system, but I do not know the details. How does…
Randomblue
  • 2,610
  • 2
  • 17
  • 38
21
votes
9 answers

How to get contract's ether balance at hardhat / waffle

I writing hardhat/ethers/waffle unit tests for my contract and need to know Ether balance of my contract. Chai matcher changeEtherBalance needs Signer object to check balance, but I have address of my contract only. I know, what ethers.js has…
Bogdoslavik
  • 331
  • 1
  • 2
  • 6
21
votes
5 answers

How do I import my presale wallet?

I purchased ether during the presale. Is there an easy way to import those ether and start using them?
Ethan Wilding
  • 4,821
  • 7
  • 24
  • 31
21
votes
2 answers

What is the difference between the STATICCALL and CALL EVM opcodes?

Besides the regular and very common CALL, the Ethereum Virtual Machine has the STATICCALL opcode. In which ways does it differ from the regular CALL? Edit: This is not a duplicate because this question is about STATICCALL, that question is not!
Jesbus
  • 10,478
  • 6
  • 35
  • 62
21
votes
3 answers

Why does ethereum creates a new block,without even a single transaction?

I'm running a private Ethereum blockchain. When I set one of the nodes to mine, that node continuously creates blocks, even if there are no transactions inside of it. What is the purpose of this?
Heisenberg
  • 313
  • 2
  • 6
21
votes
6 answers

How to convert an address to bytes in Solidity?

What is the recommended way to convert an address to bytes in Solidity?
eth
  • 85,679
  • 53
  • 285
  • 406
21
votes
6 answers

Solidity Error: Struct containing a (nested) mapping cannot be constructed

My version of solc: "solc": "^0.7.1", When I try to construct a struct that contains mapping, I got this error: "Struct containing a (nested) mapping cannot be constructed" This is my solidity code. Campaign.sol pragma solidity >=0.5.0; contract…
Sang-hoon Shin
  • 425
  • 2
  • 4
  • 9
21
votes
1 answer

Getting private keys of geth accounts

Just the opposite of this question How to import a plain private key into geth or Mist? I would like to know how can I obtain the private keys of the accounts created with geth in this way: $ geth --testnet account new I've been looking for private…
21
votes
3 answers

Does an entire transaction revert when throw occurs?

I have a contract that calls another contract that calls another. If there is a throw (or out-of-gas error) that occurs somewhere in the second contract, does the entire transaction get reverted or is it just the stuff in the second and third…
ZMitton
  • 2,750
  • 4
  • 19
  • 34
21
votes
4 answers

Can solidity contract arrays receive arrays of addresses as parameters?

This question is related to this one but using address arrays instead of strings. Does solidity support arrays of addresses to be passed as method arguments? contract C { uint256 hexVal = 0xABCD; function func(address[] addrs) { //…
Sebi
  • 5,294
  • 6
  • 27
  • 52
21
votes
2 answers

What are best practices for serving a DApp over HTTPS, connecting to an Ethereum node using JSON RPC / web3.js, which by default uses HTTP?

Summary: we're serving an Ethereum DApp from a webserver through HTTPS. The DApp connects to an Ethereum node through JSON RPC using web3.js, which uses HTTP (not HTTPS). How to deal with this in a good way? It's good practice to serve web content…
AronVanAmmers
  • 483
  • 4
  • 9
21
votes
4 answers

Does Web3.js have the functionality to create new accounts and unlock an account for a period of time for a series of transactions?

I want to create new accounts through my Dapp web interface and unlock a specific account so that transactions can be processed. I didn't see it in the web3.js documentation so wonder if that's on the web3.js roadmap?
Alan Wunsche
  • 1,655
  • 2
  • 16
  • 19
21
votes
4 answers

How can the transaction status from a thrown error be detected when gas can be exactly the same as the gasUsed for a successful transaction?

This question arose from answering Transaction Status. In the following example, I am sending gas of 21,000 (the amount required for a regular transaction). In this situation gas == gasUsed, and so cannot be used to determine if the contract has…
BokkyPooBah
  • 40,274
  • 14
  • 123
  • 193