Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [solidity]

Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed for writing smart contracts in Ethereum to run on the EVM. Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features.

2
votes
1answer
127 views

Has anyone found a fix for “ParsedContract.sol:3:1: ParserError: Source file requires different compiler version”?

Following the truffle pet shop tutorial and ran into this error when running truffle migrate: ParsedContract.sol:3:1: ParserError: Source file requires different compiler version (current compiler ...
0
votes
1answer
52 views

Downloading a specific version of solc within a Docker image

I am working with the release of Solidity v0.4.25 for it works well with py-solc. When running on a local machine the codebase works quite well with 0.4.25. My issue currently is to get the codebase ...
0
votes
1answer
13 views

SC Truffle Testing: Domain Object Returned?

Working through some tests in Truffle to become more acquainted with the environment but am running into an issue. What I am trying to do Test a smart contract with, among others, the following ...
-1
votes
0answers
11 views

How to maintain a list of static messages and validate a transaction in solidity?

How do I write a solidity contract such that I maintain a list of messages (By message I mean to say a struct with a bunch of fields) and when a transaction comes in I want to see if the transaction ...
1
vote
1answer
40 views

Returning Struct Array in solidity

contract TripHistory { struct Trip { string lat; string lon; } mapping(string => Trip[]) trips; function getTrip(string _trip_id) public view ...
-1
votes
0answers
26 views

Require msg.sender.balance not work correct in payable function

I create payable method in my contract. All works good, but when I add condition about balance of sender I catch error: "VM Exception while processing transaction: revert": Method buy is below: ...
-1
votes
0answers
27 views

Error: VM Exception while processing transaction: invalid opcodes voting system

I encounter this error in my voting project and can't figure out why.. can anyone help or explain at least.. i'll attach my smart contact and js file.. //smart contract pragma solidity >0.4....
2
votes
2answers
23 views

Missing 1 ether after transfer call?

I made a small contract test like: contract Test { function send() payable public { address payable recipient = 0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C; recipient.transfer(...
-1
votes
0answers
20 views

Address array is not returning any of the address

I have create the variables to store the list of address and the funds by every investor. In etherscan.io, When I tried to check the investor list I could not see anything. Could you please let me ...
0
votes
1answer
19 views

How to use event log in solidity contract using go language

I have created ethereum smart contract using go language. Smart contract successfully deployed. I have a created many transactions on ethereum private network. But I confuse how to get event log.
0
votes
1answer
48 views

Is there a way to set specific account when using truffle console rinkeby?

When I tested on ganache-cli at local, I could test on 'truffle console development' with some accounts which ganache-cli gave. But at rinkeby, I can't use function_name(argumets, {from: specific ...
0
votes
1answer
20 views

HDWallet Provider vs HttpProvider

What exactly is the difference between HDWalletProvider and HttpProvider, and what is the proper scenario for using each?
0
votes
1answer
42 views

Truffle and Ganache-cli test case fails

So I have this setup : truffle and ganache-cli I'm sending some ether to my contract, here is the related part of my contract: mapping(address => uint256) public balanceOf; function () ...
1
vote
1answer
40 views

unable to understand how to use internal function types

I need help to understand below code which is from solidity offical documents "how to use internal function types". as it is very confusing for me. How to use library in solidity. Some one explain ...
-1
votes
0answers
19 views

HTML file created in truffle setup is not getting launched in chrome

I have used truffle to compile the contract and create the ABI files. Now I need to point the ABI files in the HTML file. I have used the HTML code as mentioned below Question When I executed in ...
0
votes
1answer
22 views

i have erorr when sendTransaction web3

file javascript //smartcontract window.onload = function() { if (typeof web3 === 'undefined') { document.getElementById('metamask').innerHTML = 'Instal metamask dulu' ...
-1
votes
1answer
32 views

How to concatenate string array into a single string

I am trying to concatenate a whole array of string into a single array for printing purpose. function getArray() public view returns (string) { arr.push("Max"); arr.push("good"); arr....
1
vote
1answer
26 views

How State variable are stored and updated?

The Smart contract and the state variables are stored in the blockchain, let us say during deployment of a smart contract the state variable and smart contracts are stored in the block 1, and in ...
-1
votes
0answers
28 views

How can I pass one tuple element to the constructor?

I have the following problem: contract A { uint internal m_Index; constructor(uint pIndex) public { m_Index = pIndex; } } contract B is A { address public ...
0
votes
1answer
40 views

Is there a way to know the REAL msg.sender?

I want to know the real msg.sender of the transaction. Which this means is, if I use truffle console I can change the msg.sender by using {from: another address}. So let's say my address is A, and ...
1
vote
1answer
19 views

web3.eth.sign sometimes gives V parameter of 54 or 55, ecrecover then fails. What's going on?

I've been using ecrecover and web3.eth.sign to authorize transactions, but when I run web3.eth.sign a second time on my server, the V part of the signature is wrong(or, at least, ecrecover thinks it's ...
-1
votes
0answers
27 views

Solidity function and return statement

Can somebody please guide me what is the meaning of following statement in Solidity? function g(uint a) returns (uint ret) { return f(); }` Zulfi.
1
vote
0answers
40 views

Etherscan Verifying Contract Code: Error! Constructor arguments provided but might be unncessary because source code contains a public constructor

I'm trying to verify my solidity code through etherscan but it gave me this Error! Constructor arguments provided but might be unncessary because source code contains a public constructor. Tip: ...
3
votes
2answers
96 views

factory contract storage patterns

i'm new to solidity and trying to understand the better storage option for the factory contract. i want: to be able to get all deployed contracts. to be able to get all deployed contracts by creator ...
2
votes
1answer
38 views

solidity ^0.5.0 factory pattern mapping apprach

new to solidity. Trying to understand the better approach for using a mapping storage in factory contract. 2 options: Use mapping(address => Contract[]) Use mapping(address => address[]) ...
3
votes
1answer
26 views

Why is multidimensional array declaration order reversed?

Why is multidimensional array declaration order reversed? As an example, an array of 5 dynamic arrays of uint is uint[][5] (note that the notation is reversed when compared to some other ...
1
vote
2answers
50 views

Getting ParserError: Expected ',' but got 'payable' and also one important security issue with contract

I have write a small smart contract for lottery system. however there is problem. please see below full code. pragma solidity >=0.4.22 <0.6.0; contract Lottery{ address[] public players; //...
1
vote
1answer
22 views

How can I execute transferFrom function in node js

There is solidity erc865 code function transferFromPreSigned( bytes _signature, address _from, address _to, uint256 _value, uint256 _fee, uint256 _nonce ) public ...
1
vote
1answer
25 views

Need to use function modifiers however little confuse when implement and how

Hi I need help for writing below auction code. I want to use modifier however there is some changes in solidity which make me confuse. I have mentioned below where I need changes within "//" pragma ...
0
votes
1answer
29 views

Impossible to transfer my token via Token.transfer or Token.transferFrom

Everytime I’m trying to make a transfer I’m having an error, every other methods seems to work except transfer & transferFrom. I’m having an issue with my “token.transfer” (token is my ERC20), ...
2
votes
0answers
23 views

Can I send transaction to a view|pure function?

This is the contract: uint public result; address public owner; constructor() public { owner = msg.sender; } function add(uint a, uint b) public returns(uint) { result = a + b; return ...
1
vote
0answers
39 views

Is there a way to calculate gas usage of external function call?

I have an external view function which has an iteration loop. If the contract's totalSupply gets bigger, then the iteration time will grow as well. I'm testing on rinkeby right now, but when I launch ...
0
votes
1answer
17 views

Can solidity alone suitable for ICO project?

I know solidity codes and coded one smart contract.I want to know is if I want to list this contract on one exchange.is it ok or not. can this exchange accept this codes to exchange with other coins?
-1
votes
0answers
9 views

Retrieving huge data using Read contract in MEW / Etherscan

I have a contract which may return around 30000 address. Will I have any issues like returing only the partial data ? If this is not the best way to retrieve the huge data.. could you please ...
1
vote
0answers
13 views

Web3JS throws InvalidResponse without Ganache core ever receiving a request?

Versions: Ubuntu 18.04 LTS Node.JS: 8.3.0 WebJS: web3: ^1.0.0-beta.37 web3-utils: ^1.0.0-beta.36 npm: 5.6.0 Truffle version 5.x (latest) I have traced through the HttpProvider code in the Web3 ...
0
votes
1answer
25 views

How to save and retrieve the investors address in a crowdsale contract

I am writing a ICO code which should have the following functionalities To save the address of every investor and To retrieve all the investors address and the amount invested Question What is the ...
0
votes
1answer
20 views

Storing keccak hash in bytes32

I am using keccak hashing algorithm for converting documents to hashes, the algorithm is producing hashes like: **8185f41244d1a00110cff37b60732228623a82e7da905cac00777029887816ff** I want to ...
3
votes
1answer
24 views

What is the default license for solidity code released to the blockchain?

What is the default license for solidity code released to the blockchain? Is there such a thing? I'm just wondering because i thought the idea of smart contracts is to release the source code, so ...
0
votes
1answer
119 views

getting error TypeError: Member “transfer” not found or not visible after argument-dependent lookup in address

Hi I need one help as I am unable to run below logic in solidity as some change in solidity. function transfer_balance(address recipient_address, uint amount) public returns(bool) { if(msg....
0
votes
1answer
46 views

Solidity test file reaches gas limit due to imports

I have a sol contract X.sol and a sol test file TestX.sol. X.sol is large: ~4m Gas after optimisation TextX.sol compiles, migrates and executes tests fine when just executing a single test - testY, ...
1
vote
2answers
46 views

Who generates the mathematical problem for miners?

In POW miners solve an problem for successfully mining a block, who provide the question to the miners ?, does all miners work on same problem ?, and how the miners verify the answer ?, if the problem ...
0
votes
1answer
49 views

remix ERC223: This contract does not implement all functions and thus cannot be created

I can't implement ERC223 contract. remix said " This contract does not implement all functions and thus cannot be created." please tell me what bad it is. pragma solidity ^0.4.25; library ...
1
vote
2answers
52 views

Is there any kind of locking protocol in Ethereum?

Is there any kind of locking protocol in ethereum, like can two transaction update the state variable same time ?, If yes then how would you avoid that ? Smart Contract XYZ is deployed and two people ...
0
votes
2answers
33 views

Suggestion on my asset contract

I created asset transaction smart contract. Functions are Create Assets (asset id, asset details, with owner) and pushing into array list. Get Assets by owner address: Looping assets array and get ...
0
votes
1answer
55 views

What changes to make in smart contract to comply with next constantinople hard fork

Constantinople hard fork in Ethereum is upcoming. So what are the changes we have to make in smart contract to comply with it? I read this: https://www.coindesk.com/ethereums-constantinople-hard-fork-...
1
vote
1answer
26 views

Converting tokens with different decimal places

Hi let's say I have a smart-contract that converts one erc20 for another erc20. erc20A is set up with 18 decimals erc20B is set up with 6 decimals i want to convert 10 erc20A tokens to 10 erc20B ...
0
votes
1answer
36 views

Sign message (obtain v,r,s) inside Solidity

I'm trying to call an Exchange SmartContract which is POORLY designed/implemented and forces you to sign your own parameters instead of using msg.sender (and provides no alternative). <-- I've just ...
0
votes
2answers
33 views

Is it ok to store tokens at 0x0?

I would like to store tokens somewhere else than my wallet due to security reasons. I made a voting system contract and when more than 50% of authorized voters vote for yes, contract transfers limited ...
1
vote
1answer
20 views

truffle web3 synchronous request problem

Error: Web3ProviderEngine does not support synchronous requests. That's what I get when I use the following command from Truffle Console: truffle(ropsten)> web3.eth.getBlock('latest').then(...
0
votes
1answer
25 views

estimateGas for function calls

Can someone suggest me how to use estimateGas for function calls like below: await (MyContract.methods.addDoc(id,sha256hash).send({from: coinbase[0],gas: 1000000})