Questions tagged [solidity]

Solidity is a language for smart contracts for blockchain technologies like Ethereum. It is designed to compile code for the Ethereum Virtual Machine. Use this tag for questions about programming smart contracts using the Solidity language.

Solidity is an object-oriented language whose syntax is similar to that of ECMAScript, but with static typing, and it is designed to compile to code for the Ethereum Virtual Machine for use in smart contracts in blockchain technologies.

6642 questions
9
votes
2 answers

How to get Ethers.js response data

Solidity: function ping() public view returns ( uint ) { return 999999999; } function ping2() public returns ( uint ) { return 999999999; } Javascript Ethers.js: (await contract.ping()).toString(); //-> 999999999 ( correct ) (await…
Om Solari
  • 207
  • 1
  • 4
  • 13
9
votes
1 answer

Does Solidity have HTTP request function?

I am making a project using Ethereum. In this project , I am making a contract called "A". When I send a message to "A", I want "A" to make a web request. Is it possible that Solidity requests using http (method GET/POST )?
문효범
  • 93
  • 1
  • 4
9
votes
2 answers

What is the difference between pure and view modifiers in solidity?

The code results in same output. pragma solidity ^0.5.0; contract mycontract { function add(uint c, uint d) public pure returns(uint) { uint e=c+d; return e; } function add(uint j, uint k) public view returns(uint) { uint…
9
votes
6 answers

Code not compiling in nodejs,throws out an unexpected error(Web3.js)

I tried following this repo:- But I am getting the following error on compiling the code with :- code = fs.readFileSync('Voting.sol').toString() solc = require('solc') compiledCode = solc.compile(code) It throws out this…
abhinayak
  • 143
  • 2
  • 8
9
votes
8 answers

Uncaught Error: Returned values aren't valid, did it run Out of Gas?

I'm listening to events of my deployed contract. Whenever a transaction gets completed and event is fired receiving the response causes following error: Uncaught Error: Returned values aren't valid, did it run Out of Gas? at…
Ferit
  • 8,692
  • 8
  • 34
  • 59
9
votes
2 answers

Composition over inheritance in Solidity - Gas efficiency

In OOP languages, composition over inheritance is a well-known best practice. Solidity is an OOP language too but there is also the gas efficiency issue. Question is, in Solidity, how do composition and inheritance compare to each other considering…
Ferit
  • 8,692
  • 8
  • 34
  • 59
9
votes
4 answers

How can we generate multiple random number in ethereum?

I want my smart contract to return 7 or 8 UNIQUE random numbers ranging from 1 to 100 upon calling the contract. What can be the best approach to obtain such result?
Joe Mutti
  • 137
  • 1
  • 8
9
votes
3 answers

How to modelize smart contracts in UML?

I am looking for a way to modelize ethereum smart contracts interaction using a modeling language like UML. I have the following serivce Contract: contract ServiceContract { constructor (address _storeC, address _quizC, address _signC) { …
maroodb
  • 1,026
  • 2
  • 16
  • 28
9
votes
1 answer

Msg.sender does not work inside a "view" function, why? Is there a workaround?

I want to create a viewable function (needs to return a string to the user) that searches a mapping for msg.sender and if the senders value is x, I want the contract to proceed accordingly. It all does work inside remix but if I upload it to…
scoperationX
  • 127
  • 1
  • 9
9
votes
1 answer

Data on Private Ethereum blockchain lost/disappears after couple of days

I am deploying a private ethereum blockchain (geth) on a virtual machine on Azure. Upon deploying my Solidity contracts on the blockchain and launching my NodeJS application to it, I am able to add data normally through web apis of the nodejs…
Ghassan Zein
  • 4,089
  • 3
  • 19
  • 30
9
votes
1 answer

Why am I getting exceeds gas limit error when I specify the exact gas limit?

I am deploying a contract using truffle, and when I specify the gas limit as the gas I want to use for the transaction I always get the exceeds gas limit error. Why does this happen? edit What I am trying to do is deploy the crypto kitties…
yemista
  • 433
  • 5
  • 15
9
votes
4 answers

Solidity accessing private variable

currently, I'm practicing solidity. However, I'm a little confused about accessing a private variable in a contract. For example here; address private a; address private b; mapping (bytes32 => uint) public people; mapping (bytes32 => mapping(address…
riyoz
  • 431
  • 1
  • 6
  • 15
9
votes
2 answers

Can't send transaction even if I use an example from official Ethereum webpage

I write Crowdsale using this example. But I can't send a transaction, my test fails with an error: Contract: Crowdsale should accept payments after start: AssertionError: expected promise to be fulfilled but it was rejected with 'Error: VM…
rel1x
  • 2,351
  • 4
  • 34
  • 62
9
votes
2 answers

Solidity return function why the constant?

I am just starting with solidity. I have a function like so: function get() constant returns (uint) { return storedData; } What is the use of the constant keyword here? I understand that after this keyboard we are defining the return type but…
Kex
  • 8,023
  • 9
  • 56
  • 129
9
votes
3 answers

Solidity-Type address not convertible to type uint256

I created an array of structures and then tried to get the values of each account of an array. But I failed with an array while passing the address variable which contains msg.sender and the type is not visibly convertible to uint256. How can I do…
Zera Abhraham
  • 91
  • 1
  • 1
  • 2