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.

1,598 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
12
votes
1answer
754 views

Trying to compile example code from pyethapp tutorial

I am trying to follow this example: https://github.com/ethereum/pyethapp/wiki/The_Console However, at the point where I should compile the code, I get an error: In [34]: print c contract NameReg{ ...
7
votes
2answers
304 views

Is there the opposite function for evm_increaseTime?

I'm using the following function in my JS tests (with truffle) to move forward in time to test time dependent functions: const timeTravel = function (time) { return new Promise((resolve, reject) =&...
7
votes
2answers
402 views

Error: “message”:“function \”Ballot\“ arguments must include \”proposalNames\“”}

I am trying below code to write Voting Contract referring to Solidity documentation pdf. Code compiles without error but I am getting below error while deploying. writing Ballot to app\meta\Ballot\...
6
votes
2answers
2k views

Conversion of address to string in Solidity

The Solution given in Convert address to string did not help. Motive: To convert an address to string type so that I can use it as a parameter to a function for which string type is necessary. Code ...
5
votes
4answers
3k views

“Mock compiler : Source not found” Error in Remix online IDE

I haven't been able to compile any solidity code because of this error. How do I solve this problem?
5
votes
1answer
351 views

How to access dynamic list from web3?

In my application players can create and join games. I store every game in a mapping(uint => Game), and send out a GameCreated event whenever a game is created. My issue is efficiently getting a list ...
5
votes
1answer
1k views

Solidity: How could I decrease gas usage of complex structs?

Struct is very expensive as labelled here: It seems extremely expensive when storing struct type. https://www.cryptocompare.com/coins/guides/what-is-the-gas-in-ethereum/: sstore 100 Paid ...
4
votes
0answers
32 views

String Input of three numbers (comma seperated) doesn't work in Remix

So when I try to put in three numbers as a String in a usual setter-method, it doesn't work. Does anybody know why? function test(string memory x) public view returns(string memory){ return x; }...
4
votes
0answers
96 views

Retrieve CHAIN_ID of the executing chain from a Solidity contract

Is there a way to directly be able to retrieve CHAIN_ID information about the executing chain from a smart contract? I know that for any chain that has EIP-155 implemented, CHAIN_IDs are retrievable ...
4
votes
2answers
274 views

Capturing an event fired from a contract that was called from another contract

I'm trying calculate tax on arbitrary items/values. To do this I have a single contract is used as an 'Oracle' to get the tax from an external system. This contract defines functions to be called from ...
4
votes
1answer
316 views

Truffle test fails to call the base function, wants the override

I have an extended ERC20 contract with ERC827 functions, which are overrides of ERC20 with an extra callback parameter. I have these two pairs of base/override functions: Base: function ...
4
votes
1answer
246 views

How can I maintain a sorted list in my smart contract?

Is it crazy to feel the need to sort solidity arrays? Imagine implementing a market (double action) you need to sort the orders. I could imagine other usecases where sort is useful. But as we all ...
4
votes
1answer
927 views

how to call smart contract function in C#.net core

protected async void Page_Load(object sender, EventArgs e) { var senderAddress = "0x605a1f8d368cbdd4d0a5cbad74f75c428660f17b"; var password = "zxcasdqwe123"; ...
4
votes
1answer
367 views

Solidity link to external library address - use Lib for uint256 breaks

I am hoping to link my contract to an external library by defining 1) an interface contract that defines the library functions and 2) the main contract that refers to the actual library address. My ...
4
votes
0answers
639 views

Truffle migrate Error Invalid number of arguments to Solidity function

Truffle 4.0.1 I've got a contract declared "is Pausable" (OpenZeppelin framework) and I want to pause it as part of the deployment logic. I'm getting an error, however, when invoking pause() Error: ...
4
votes
0answers
105 views

Autorefill isn't working on Improved Coin code

I've been trying to write a token contract with the autorefill function, but perhaps the code for the token example on the ethereum website is somewhat outdated, because it isn't working. Did anybody ...
4
votes
1answer
218 views

Does the new receipt status field report all errors all the way down the call chain?

See this transaction on etherscan: https://etherscan.io/tx/0xd20a95a9f051d6961ca766a9b2d0f18b6afdf6d8465931a3f70f2c4b1c023688 Notice the odd note saying some part of that transaction failed but the ...
4
votes
1answer
193 views

How to use BTCRelay for my ICO to get funds in BTC?

I want my ICO get investment in BTC also ,When i browse over internet I came up with BTCRelay concept . I tried to read their docs but it make me confused .Anybody give me a simple way to use BTC ...
4
votes
2answers
2k views

Web3js - “The returned value is not a convertible string”

Can someone please help me. While trying to invoke a constant function which returns string, I am getting "Promise RejectedError: ERROR: The returned value is not a convertible string:" ...
4
votes
1answer
673 views

Call write function, which doesn't change contract value

I'm new in smart contracts and faced with one problem. After deploying contract to my test local blockchain network, i try to set new value via setter, after that I call get method of contract and it ...
4
votes
0answers
585 views

How to update the Ethereum Wallet Solidity Compiler

I'm using the latest Ethereum Wallet version which is 0.9.0 and I want to update my latest Solidity compiler since it seems that the wallet is using this version 0.4.13+commit.0fb4cb1a.Emscripten....
4
votes
2answers
576 views

Importing a contract from another contract in NodeJS app

I'm using a function in my NodeJS app to deploy contracts. The user inputs the contract he wishes to deploy and the app deploys it. The structure of the app is . ├── app │   ├── models │   │   └── ...
4
votes
1answer
579 views

How to send an ETH address from a webpage to a smart contract?

What's the best way to get an ETH address from a website form submission (php) passed to a smart contract in order that the smart contract can send some new minted Tokens to the ETH address collected ...
4
votes
0answers
278 views

Gas cost for bigInt library

I am working on a big integer library in the online compiler. Currently having gas/computational time issues with the modulus function. I first implemented it using repeated subtraction: function ...
4
votes
1answer
646 views

Sending string to deployed contract function

var source = fs.readFileSync("./vote.sol", "utf-8") var compiled = web3.eth.compile.solidity(source); var abi = compiled.identify.info.abiDefinition; var Vote = web3.eth.contract(abi); var ...
3
votes
0answers
13 views

Any known implementations for on-chain merkle proofs of historical balances?

I know it is possible to verify historical ETH balances (for the last 256 blocks) using a merkle proof on-chain - are there any known implementations? NB - I'm looking for Solidity code (i.e. on-...
3
votes
1answer
44 views

Matrix multiplication in solidity

I am trying to implement an algorithm requiring matrix multiplication. I know I can program this in the rudimentary way similar to doing the process by hand, but I am worried about the computational ...
3
votes
2answers
31 views

Auction contract problem regarding highest bid display

I have an Auction contract which has a function like this: function bid() payable{ //calculate and store highest bid value } But because each transaction takes time to mine, so when a user bids ...
3
votes
0answers
90 views

VM revert on Scalar Multiplication in pre-compiled contracts

I tried to build a wrapper around the precompiled contracts as follows: https://gist.github.com/AlexXiong97/9c24bbd4541323a61fa63100860a5f89 If you paste it into Remix and deploy it, inputting any (...
3
votes
1answer
39 views

Order of evaluation: an example

In the Solidity documentation is stated that: The evaluation order of expressions is not specified (more formally, the order in which the children of one node in the expression tree are evaluated ...
3
votes
0answers
58 views

One-to-many mapping inside struct

I have two structs: struct A{ uint bid; mapping(uint => B[]) BMap; //bid - index for struct B } struct B{ uint cid; } mapping(uint => A[]) AMap; How can we push and fetch 'cid' ...
3
votes
1answer
47 views

How to use enums for conditions on constructor?

I am learning to code with solidity. need help to solve this I have a membership system where users can have basic, gold, diamond membership types. Users can use coupons every 5 minutes and for basic ...
3
votes
0answers
147 views

Questions on MinterRole contract in openzeppelin

I am using the openzeppelin for creating the ICO contract. I am concerned about the MinterRole here. After I develop Token contract, I added the sale contract as a minter using "addMinter" function. ...
3
votes
1answer
47 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 ...
3
votes
2answers
57 views

Format of Event logs structure in Remix

I am running a simple contract in remix. I have an event in my contract which will be emitted just to check values of stateVariables. contract stateVariable{ uint stateVariable1=10; uint ...
3
votes
2answers
743 views

Truffle Compile with Solidity 0.5.0

I just upgraded my code to Solidity 0.5 and am trying to use the truffle framework with it. I did update my code in Remix and it does seem to work. The problem I have is that I am unable to compile ...
3
votes
3answers
328 views

How to handle dynamic size string array in solidity?

I have a shop owner and a shop owner can have multiple products. I want to keep the products id in an array. Also, A public method can return all the product id list of a shop owner. I tried the ...
3
votes
0answers
121 views

solc: [libevmasm/CMakeFiles/evmasm.dir/Assembly.cpp.o] Error 1

I am trying to install solc v0.4.25 through brew on a Mac. Please note that I was able to install its latest version solc v.0.5.0 using brew install solidity; but I am unable to install its previous ...
3
votes
3answers
245 views

Inability to verify contract with ABIEncoderV2 on Etherscan

Yesterday I deployed a contract to Ropsten (https://ropsten.etherscan.io/address/0x1fe59c223fa4e9781237f0f49a15ca598069cc30) that relies on V2 of the ABI encoder. Thus it includes statement pragma ...
3
votes
0answers
29 views

Delegatecall Scope - Correct me if I'm wrong

When any contract function is called - delegatecall or otherwise - the EVM loads the requisite pointers & values into that call frame's volatile stack/memory. Example: Let's say we have contract ...
3
votes
2answers
106 views

Check your gas amount error ERC721

I am trying to deploy contracts to Ganache for testing using Truffle, but no matter what I set gas price / gas limit / gas to both in truffle.js and Ganache itself, it always get check gas amount on ...
3
votes
1answer
633 views

Drizzle cacheCall is not updating data correctly

I have a react component which is interacting with a solidity contract via drizzle. I store a cacheCall index in the constructor: this.opcTokenCacheCallIndex = context.drizzle.contracts.OPCToken....
3
votes
2answers
1k views

Error: gas required exceeds allowance or always failing transaction upon function execution

Problem The transaction fails because the transaction ran out of gas instead of it failing because the require condition was not met. It works fine before the solidity update to version 0.4.24. It ...
3
votes
0answers
83 views

Why does this work with Solidity 0.4.21 but not 0.4.22?

I have this simple set of contracts. pragma solidity ^0.4.21; contract FirstContract { bool public isTrue = true; function sayHello() public pure returns(bool) { return true; } } ...
3
votes
1answer
1k views

how get a revert message

I have this example contract. contract Example{ function foo(){ revert("hello world!!!"); } } When execute the foo function, this revert the tx, how get the revert message? ...
3
votes
1answer
429 views

Ganache (UI) save blockchain

I am running a testnet on Ganache UI. But when I deploy a contract and close and reopen ganache, there are no blocks and the contract deployment is gone. Is it possible to save/load a blockchain ...
3
votes
1answer
608 views

ERC223 Token Fallback Function Usage

I'm currently writing the "Trade" smart contract which is similar to "Crowdsale" smart contract. The only function that I want to add is "sell" function. In general Crowdsale smart contract is used ...
3
votes
0answers
90 views

How to parse through the logsBloom of a block or transaction using solidity

Currently trying to figure out how to parse through the logsBloom portion of block and transaction headers using solidity. I've researched the topic so far and have come to the understanding that RLP ...
3
votes
0answers
115 views

Solidity : About function calls between deployed contracts

I want to make a function call between a token (MyToken.sol) that inherits MintableToken.sol of OpenZeppelin and manipulate that token (Buy. Sol). (MyToken.sol) pragma solidity ^0.4.21; import "...
3
votes
0answers
266 views

Testing solidity default function with Truffle and async/await

I am developing a crowd sale contract in solidity. The fallback function is payable so that investors can send ether to the contract. If incoming transaction is accepted then information about the ...