Questions tagged [ethereum]

Ethereum is a blockchain currency (like Bitcoin) with a public ledger. Questions should relate to programming. General questions about Ethereum should be asked on https://ethereum.stackexchange.com

is an open-source, public, blockchain-based distributed computing platform featuring smart contract (scripting) functionality. It provides a decentralized Turing-complete virtual machine, the Ethereum Virtual Machine (EVM), which can execute scripts using an international network of public nodes. Ethereum also provides a cryptocurrency token called , which can be transferred between accounts and used to compensate participant nodes for computations performed. Gas, an internal transaction pricing mechanism, is used to mitigate spam and allocate resources on the network.

was proposed in late 2013 by Vitalik Buterin, a cryptocurrency researcher and programmer.

The official website of is Ethereum.org

6757 questions
26
votes
11 answers

How to generate a random number in solidity?

I have a couple of keccaks, which could be reduced to one if I would find a cheap way to get parts of the created uint. pragma solidity ^0.4.19; contract test { function test() { } function sup() returns (uint test) { uint _test =…
Garry Plays
  • 377
  • 1
  • 3
  • 5
26
votes
2 answers

Where do smart contracts reside in blockchain (Ethereum or Hyperledger)

So, let us consider a typical trade finance process flow. Exporter deploys a contract that has conditions of the shipment and a hash is generated once the deployment is finished. Questions: 1) Where is the contract stored? 2) How other…
Saurabh
  • 1,249
  • 2
  • 13
  • 14
25
votes
4 answers

Set gas limit on contract method in ethers.js

Problem I am trying to use a method of a contract on the test network (ropsten), but it fails due to this error: reason: 'cannot estimate gas; transaction may fail or may require manual gas limit', code: 'UNPREDICTABLE_GAS_LIMIT' Code I created an…
Gh05d
  • 7,923
  • 7
  • 33
  • 64
25
votes
4 answers

How to return mapping list in Solidity? (Ethereum contract)

I want to make a simple smart contract that has a list, can set item, and can get the list. Code in solidity: contract lister { mapping(int => string) list; int id = 0; function getList() returns ( /*HERE*/ ) { return list; …
6londe
  • 557
  • 1
  • 8
  • 17
24
votes
15 answers

npm solc: AssertionError [ERR_ASSERTION]: Invalid callback specified

I am trying to compile solidity smart contract using npm solc. I tried to follow different examples. Link to example: https://medium.com/coinmonks/how-to-compile-a-solidity-smart-contract-using-node-js-51ea7c6bf440 I wrote my code like…
Mouazzam
  • 469
  • 1
  • 4
  • 15
23
votes
1 answer

How would I send an eth value to specific smart contract function that is payable in ethers.js?

I'm trying to call a payable function on a smart contract that only accepts one argument. How would I send an eth value to this function in ethers.js along with the function call? The docs don't seem to give much examples on the best way to do…
23
votes
11 answers

solidity transaction error, The called function should be payable if you send value and the value you send should be less than your current balance

I'm learning solidity on remix. I was following some tutorial video on youtube and I've got stuck trying to build 2 contracts. contract ERC20Token has function which increases balances. And Mycontract instantiates and call the mint function. I did…
Baaam Park
  • 415
  • 1
  • 5
  • 7
22
votes
9 answers

String array in solidity

I came across quite a common problem that it seems I can't solve elegantly and efficiently in solidity. I've to pass an arbitrary long array of arbitrary long strings to a solidity contract. In my mind it should be something like function…
Fabio
  • 415
  • 1
  • 5
  • 14
22
votes
14 answers

String concatenation in solidity?

How do I concatenate strings in solidity? var str = 'asdf' var b = str + 'sdf' seems not to work. I looked up the documentation and there is not much mentioned about string concatenation. But it is stated that it works with the dot ('.')? "[...] a…
tObi
  • 1,864
  • 3
  • 20
  • 32
21
votes
6 answers

How to Logout of MetaMask account Using web3.js

I am using MetaMask for sending transactions to contract in my DApp. I need help in How to Disconnect MetaMask account from my DApp when the user clicks on logout button. Front-end: ReactJS Back-end: Web3js, Solidity (Ethereum)
Umair Janjua
  • 324
  • 1
  • 2
  • 11
20
votes
2 answers

How to trigger change blockchain network request on MetaMask

I am using web3 for my first dapp test and I'd like to make so MetaMask will prompt the user to change the network to Binance (BSC) network if it is not selected already, just like here: How to trigger such a request?
Andrea D_
  • 2,028
  • 3
  • 15
  • 38
20
votes
2 answers

what approve and allowance methods are really doing in ERC20 Standard?

The problem is what allowance and approve are really doing? And what is _spender and what is it doing? Is there anybody who can explain it to me? contract Token { uint256 public totalSupply; function balanceOf(address _owner) constant…
shahabvshahabi
  • 937
  • 2
  • 7
  • 18
19
votes
1 answer

what is the difference between orbitdb (based on IPFS) and gun ?

I'm looking for a decentralized database for my Dapp. I found two helpful solutions orbitdb and gun but I couldn't realize the main difference and which one is more suitable for a social-media-like application that use ethereum smart contract.
maroodb
  • 1,026
  • 2
  • 16
  • 28
19
votes
4 answers

Unhandled rejection Error: This contract object doesn't have address set yet, please set an address first

Im currently trying to use Infura to run on my machine thru Web3. When I set to run my node index.js file I get the following error: Unhandled rejection Error: This contract object doesn't have address set yet, please set an address first. at…
Steven Aguilar
  • 3,107
  • 5
  • 39
  • 89
19
votes
4 answers

How to get Ethereum transaction list by address

I'm looking for a way to get a list of transactions for a given address. If there are too many transactions I'd expect to be able to page the results. It would be better if I can give the latest processed transaction as parameter so I could get the…
Paul Exchange
  • 2,637
  • 3
  • 26
  • 33