Stack Exchange Network

Stack Exchange network consists of 175 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.

0
votes
2answers
33 views

What is wrong with this contract? [closed]

contract Vuln { mapping(address => uint256) public balances; function deposit() public payable { // Increment their balance with whatever they pay balances[msg.sender] += ...
0
votes
0answers
19 views

How to create multi forwarder address (contract)?

How to create multi forwarder address (contract)? my code https://pastebin.com/raw/ADwPtz8q error InternalCompilerError: Compiled contract not found. pragma solidity 0.4.25; contract Factory { ...
0
votes
1answer
22 views

Making assertions (assert.equal) on two return values in Truffle

Appreciate any help I can get. I am trying to make an assertion on returned values from a smart contract, and I cannot figure out how to get it to work for a Truffle test. I cannot show all my code in ...
-1
votes
1answer
45 views

what is the different between this two? [closed]

today I have two type One is like this pragma solidity ^0.5.0; contract Test{ function TestVar() view public returns(uint8){ uint8 a; for(uint8 b=0;b<20; b++){ a=b; } ...
1
vote
3answers
68 views

how do I loop through a mapping of address [duplicate]

I have a mapping of list of struct (mapping (address => struct[])) I'm having a trouble in how to display all them together in the front end (i'm using React js). Thnx.
0
votes
1answer
33 views

As in truffle tests pass the check by block.timestamp?

I have 2 functions function startBuilding () public { uint[8] memory _buildingInfo; _buildingInfo[1] = uint32(block.timestamp) + 2 minutes; addBuilding(...
0
votes
1answer
22 views

Decoding Hex value in solidity

I am trying to view values stored on my ethereum contract using ethereum wallet. Currently the values are being placed onto the contract in hex format. Is there a way to decode them on the contract so ...
0
votes
1answer
38 views

web3.eth.getAccounts() never give any output

const deploy = async () => { **var acct = await web3.eth.getAccounts();** console.log("ac", acct); } deploy(); even the console is not getting printed,what could be the reason? ...
1
vote
2answers
44 views

Create a blockchain platform to store students and its degree results on it [closed]

I would like to create a application on blockchain where i will store all students data and their results on blockchain So anyone having a idea how can i do that or is that feasible to create a that ...
0
votes
1answer
18 views

abi.encodeWithSignature did not work

pragma solidity ^0.5.3; contract SimpleFallback{ event FallbackCalledEvent(bytes data); event AddEvent(uint a, uint b, uint result); event DoubleEvent(uint a, uint b); event ...
2
votes
0answers
31 views

Why truffle deploy fail with address value=0 after I upgrade to version 5.0.5?

I have a truffle 2_deploy_contracts.js something like this : const sample = artifacts.require('./Sample.sol'); module.exports = function(deployer) { deployer .then(()=>deployer.deploy(...
0
votes
1answer
11 views

Error when checking the value in a mapping

I am trying to keep track of the number of bidders in my contract. function bid() public payable an_ongoing_auction returns (bool){ uint oldval = bids[msg.sender]; require(msg.value+oldval &...
1
vote
1answer
31 views

Why EVM and Solidity and not JVM and Java?

Why wasn't JVM and Java used for Ethereum? But instead, EVM and Solidity was invented for the express purpose for Ethereum?
1
vote
0answers
23 views

Truffle test {from} option is ignored

To test my contracts i need to use multiple accounts. I hoped that changing value of from option will help me with this. But it is ignored and msg.sender is always accounts[0] (my deployer) Truffle ...
0
votes
1answer
19 views

Solidity returning address to javascript when uint was requested

I'm early in learning solidity (that's probably obvious). No idea why I'm getting this result. medsToBeDeveloped has a length of 0 at begining uint [] medsToBeDeveloped; function returnProductID(...
0
votes
0answers
34 views

How to pass array of bytes to solidity function?

I have a solidity function function foo (bytes memory myBytes) {} In javascript I have an array: let myArray = [ '0xAA', '0x1', '0x55'] If I copy and paste the array into remix, my foo ...
-1
votes
1answer
27 views

Wait until smart contract function executes before continuing to loop

I have a web3 call to the smart contract which returns true or false. According to the returned value, the current element of the array is deleted or not. However this isn't working well (since web3 ...
1
vote
1answer
19 views

Ethereum transaction fails in simultaneous calls

I am making two calls simultaneous call with a single wallet. First I am making a contract call then I am making a ether transaction call. The first call succeeds, but the next call fails. I got this ...
1
vote
3answers
35 views

What mechanism to use to pay for viewing another users data on blockchain

I am new to blockchain development and following some tutorials I have created a DApp that allows a user to save and view information. Now, i want to let another user view that saved information but ...
0
votes
2answers
46 views

TypeError: Type contract testAdoption is not implicitly convertible to expected type address

pragma solidity ^0.5.0; import "truffle/Assert.sol"; import "truffle/DeployedAddresses.sol"; import "../contracts/Adoption.sol"; contract testAdoption{ Adoption adoption = Adoption(...
0
votes
2answers
56 views

Blockchain Smart Contract EHR

I'm trying to do a miny EHR(Electronical Health Record) with Smart Contracts where I have a Pacient Contract. The problem is that in solidity everything is public, even the private variables, so I ...
0
votes
1answer
26 views

Solidity: call from function to modifier with array [closed]

I have the following problem, I'm trying to call a function from Solidity function to Solidity modifier: contract B is A function checkIfIsValid() external pure onlyValidAddresses([manually put ...
7
votes
2answers
96 views

Is there a widely-accepted convention for when to use a modifier and when to use a simple assertion?

I've read this answer, which is good in general, but it doesn't quite tell me when to use a modifier (at the function declaration) and when to use assert/require (inside the function). I do ...
0
votes
1answer
17 views

ParserError: Expected primary expression

Following is my code: pragma solidity >=0.4.17; contract Lottery { address public manager; address[] public players; constructor () public { manager = msg.sender; } ...
0
votes
0answers
14 views

What does endCliff and endVesting time means in PolyMath contract?

What does vesting and cliff exactly means in smart contract and blockchain terms. Here I've added code snippet: if (_supply == AllocationType.PRESALE) { AVAILABLE_PRESALE_SUPPLY = ...
0
votes
1answer
23 views

Is a function prone to re-entrancy attack even if I set balance to zero within the same function (example included)

Such as in this scenario, is the hackable via re-entrancy? thanks... function withdraw(uint256 money) public { if(money <= balance[msg.sender]) { (bool success, ) = msg.sender.call....
1
vote
2answers
33 views

Solidity modifiers: good or bad?

I've heard arguments both for and against Solidity modifiers. On the one hand, they make the code very readable, and the intents behind the calls are very clear. On the other, they increase the ...
0
votes
2answers
37 views

Is there a way to capture the require / revert failure reason?

In my contract I have a bunch of checking at the start of a public function, something like this: require ( prx < 1e18, "Value prx too high") require ( prx != 0, "Value prx cannot be zero") if (!...
0
votes
1answer
29 views

Solidity. Truffle. Call contract function in migration file

Tell me, how through truffle, after the deployment of the contract, call one of its functions? I mean, during migration, how can I call the function of the contract? var Ownable = artifacts.require("....
-1
votes
1answer
27 views

Problem retrieving array of struct with web3js

I'm trying to return the struct values contained in array everytime i push a button thet call inserimento and ritornavalore functions. here is my code in solidity: pragma solidity ^0.5.1; pragma ...
0
votes
1answer
26 views

What does this following entity exactly means in this PolyMath contract?

Here I've added code snippet which is I'm learning right now. The following terms/ entities/ variable are not understandable why exactly it means and why it is used. - Founder, Advisor, Bonus1/2/3, ...
0
votes
1answer
25 views

solidity code warning in remix IDE

I am trying to create a smart contract using the but it is showing warning message in a string "Warning: Unused function parameter. Remove or comment out the variable name to silence this warning. ...
1
vote
0answers
22 views

Markdown syntax highliter for Solidity

Does anyone here know about an available markdown syntax highlighter for Solidity? Pygments & PrismJS do not include Solidity, Vyper.. What does ethereum.org uses for its docs?
0
votes
0answers
14 views

What does that Filter By means? in ropsten etherscan while deploying tokens on ropsten

I've deployed my token contract on ropsten etherscan. Sometimes it shows me some address besides Filter By what doed that filter by exactly means?
0
votes
1answer
20 views

Is it possible to have ERC20 token (A) own other ERC20 tokens (X, Y, Z)

I'm building a DAPP, where a user has one 'parent' ERC20 token and several other 'child' ERC20 tokens. So what I want is .... To have a parent token A, and that token owns the tokens X, Y and Z. In ...
2
votes
1answer
36 views

Where is string stored in solidity storage?

I'm trying to check where is stored a string in storage in Solidity. For testing this I'm using this code: pragma solidity 0.5.4; contract AssemblyString { string s; // slot 0 function set(...
1
vote
1answer
12 views

Function which only reads data still using gas/tx fee

I have a function call which only reads data from contract but it still costs gas to execute: function foo(int256 x) public returns (bool) { if(tuna[x].validOnce == true){ if(dog[x] == ...
0
votes
1answer
61 views

Web3 not connecting with ropsten through infura

so my truffle based application is communicating fine with my smart contracts on my private network, ganache and ganache-cli. I then deployed it to ropsten where i used the endpoint i got from infura....
0
votes
0answers
33 views

Revert on ERC20.transferFrom

I am getting Error: Returned error: VM Exception while processing transaction: revert when testing MyContract.deposit() Here are simplified versions of my code to highlight where the issue is ...
-1
votes
0answers
24 views

Declaration error: please help

pragma solidity ^0.4.16; import './SafeMath.sol'; /** * @title Equality * @dev the interface of PoSTokenStandard */ contract Equality { uint256 public stakeStartTime; uint256 public ...
2
votes
3answers
28 views

How to speed up data loading from the blockchain to the frontend?

I have a function that, according to the Unique ID of the car, gives me all its characteristics: function getCarArray(uint _carId) public view returns (uint[12] memory) ...
0
votes
1answer
17 views

How to use 2 different constructors with open-zeppelin

I don't understand well how to implement an smart contract to create a capped Token. If I want to follow the example of a simple token is easy: https://github.com/OpenZeppelin/openzeppelin-solidity/...
2
votes
0answers
30 views

Why I can't use two functions with same name, but different parameters

I have a function which returns address but it gives me error if I try to read it. I'll explain by a quick example: Solidity: contract TestOneReturn { mapping(uint => uint) m_Data; ...
1
vote
0answers
18 views

Error: Cannot create instance of X; no code at address

Having a little issue. I have deployed a Mock ERC20 contract on development network like so: const ERC20Mock = artifacts.require("ERC20Mock"); module.exports = async function(deployer, network, ...
0
votes
1answer
21 views

In truffle5, how to manipulate time with evm_increaseTime?

I am using truffle 5 and ganache-cli. I've imported increaseTime as import increaseTime from './helper/increaseTime'; and the increaseTime.js file is like this export default function increaseTime(...
1
vote
1answer
21 views

What is the Withdrawal Pattern?

I am reading this article : https://medium.com/@jgm.orinoco/why-use-the-withdrawal-pattern-d5255921ca2a It seems interesting. Could anyone explain the idea of the Withdrawal pattern in a simple way ?
0
votes
0answers
24 views

truffle cant find function from contract made with address and abi

So I have a factory contract "RestaurantFactory" which i migrate, this contract creates another contract "Restaurant", after deploying the RestaurantFactory and calling createRestaurant() I receive an ...
0
votes
1answer
34 views

can we pay the gas price in form of token?

can we pay the gas price in form of ERC20 token without using the ether? if ERC20 token has a value.then can we pay the gas price in form of ERC20 token.
0
votes
1answer
20 views

I am following Ethereum Book, but I am getting errors in the Terminal

I am learning Ethereum Development from the Ethereum Book by Andreas. I have stumbled on the first error trying to do $ cargo install . I will post the instructions as an image and the errors I got. ...
0
votes
0answers
42 views

unable to deploy contract on rinkeby network

I am trying to deploy my contract to rinkeby test network but unable to do so here is my contract code. pragma solidity ^0.4.17; contract Inbox { string public message; function Inbox(string ...