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,729 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
13
votes
1answer
770 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{ ...
8
votes
3answers
324 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) =&...
8
votes
2answers
436 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\...
7
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 ...
6
votes
0answers
56 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; }...
6
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
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? ...
5
votes
0answers
189 views

Can I `eth_call` a non constant function from javascript?

I know that I can't get the return value from a transaction (How to get values returned by non constant transaction functions?), and non-constant functions have return value because they can be called ...
5
votes
1answer
754 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 ...
5
votes
2answers
374 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
2answers
50 views

Prove that a solidity function was executable in the past

I was wondering if anyone knows a way of how to prove that a certain function of a solidity smart contract was executable (i.e. not reverting) after the fact without calling the function itself, e.g. ...
4
votes
3answers
286 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 ...
4
votes
2answers
362 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
2answers
874 views

Error! Unable to generate Contract ByteCode and ABI

Having issues verifying my token contract on etherscan.io. Receiving the following errors: Note: Contract was created during Txn# Result: Does not match the input creation bytecode found at this ...
4
votes
1answer
362 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
994 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
410 views

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

I'm trying to link my contract to an external library by defining an interface contract that defines the library functions and the main contract that refers to the actual library address. My library ...
4
votes
0answers
678 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
106 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
3answers
2k views

Correctly deploying contracts with web3 1.0 and testrpc (invalid opcode error)

I followed the following tutorial: https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2 Now this tutorial is not using the recent version of web3 but ...
4
votes
1answer
198 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
0answers
594 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
644 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
631 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
994 views

flag provided but not defined: -rpc

I'm using Geth to set up a private ethereum network and this is the command: $ geth --identity "MyTestNode" --datadir "SomeDir" init genesis.json --rpc --rpcaddr "localhost" --rpcport "8000" --...
4
votes
2answers
814 views

Contract creation gas cost depends on code in library function?

I have a contract fooContract which is using a fooLib library, calling fooLib.foo(LibStruct storage param) The transaction cost to create fooContract seems to depend on the code in the fooLib.foo() ...
4
votes
0answers
290 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
693 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
1answer
99 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
48 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
99 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
47 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
67 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
57 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
201 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
65 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
77 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
797 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
542 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
128 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
0answers
31 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
126 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
775 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
0answers
90 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
508 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
685 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
379 views

How to use logx in Solidity?

Aim: To log data from a smart contract. Following function is written in accordance with low level interface to Logs in ethereum. However, due to lack of documentation, and being new in Solidity, I ...
3
votes
0answers
97 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 ...