What's the deal with Deno? We talk with a major contributor to find out. Listen now.

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,927 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
13
votes
1answer
794 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{ ...
9
votes
2answers
505 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
0answers
271 views

SushiSwap - Inner workings?

I've been trying out in the past few days SushiSwap and lately SashimiSwap Contracts & Frontend and while I'm still getting familiar with the code. It turned out to be quite a challenge to make it ...
6
votes
0answers
67 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
0answers
198 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
852 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
400 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
2answers
941 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() ...
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
19 views

How can i do 2^0.3 (exponent below 1) using integers?

simple problem, but i can't seem to wrap my head around it in solidity. how can i do 2^0.3 (exponent smaller then 1) in solidity using integers. thanks in advance K.
4
votes
1answer
591 views

Reset all values in a mapping

I am trying to figure out how to have the balance of all players reset to (amount) when a certain condition happens. This is the function that will update a specific player balance. How do I make it ...
4
votes
3answers
394 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
456 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
2k 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
417 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
2answers
418 views

Smart Contract firing send ether transaction that's not in the contract

I need some help with my smart contract, here's the smart contract code pragma solidity ^0.4.18; contract UserToken { mapping (bytes32 => uint8) public tokenBalance; bytes32[] public ...
4
votes
1answer
1k 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
475 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
708 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
112 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
203 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
635 views

Web3 Event Filtering timeout

This is the code I use to get all events from a certain contract. Solidity: event NewEvent(address indexed contractAddress, address newBOPAddress, address payer, uint commitThreshold, bool ...
4
votes
0answers
596 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
738 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
664 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
1k 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
0answers
298 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
773 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
28 views

Sharing an event between a contract and a library

I've a contract that uses an event and I want to share it with a library without having a duplicated definition. The event is in the library, and contract uses it from the library. It works but the ...
3
votes
0answers
59 views

Unit testing a Solidity Library function with a struct memory argument

I am trying to unit test a Solidity Library contract function using truffle and web3. My simplified Library contract looks like this: pragma solidity >=0.5.16; pragma experimental ABIEncoderV2; ...
3
votes
2answers
26 views

Set and delete storage variable in same tx

I did some poking around and didn't see an answer... and I figure someone knows this off the top of their head. Question: what is the gas cost associated with setting and deleting a storage variable ...
3
votes
1answer
76 views

How to upgrade this Crowdsale contract (from DappUniverse)

i'm trying to compile this code (from DappUniversity: https://github.com/dappuniversity/ico_irl/blob/master/contracts/DappTokenCrowdsale.sol) but with the new version of OpenZeppelin, that's use at ...
3
votes
2answers
68 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
106 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
53 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
82 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
78 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
348 views

solidity-coverage show 0% coverage

I'm trying to make a test coverage for MetaCoin. This is my package.json, truffle-config.js and .solcover.js: module.exports = { port: 8555, norpc: true, compileCommand: '../...
3
votes
0answers
286 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
2answers
106 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
1answer
164 views

Web3JS incorrect return value

When I return a string array with web3 I don't get the original array as expected, but rather I get an array of the same size, with the index off by one. So instead of ["One","Two","Three"] I get ["",...
3
votes
3answers
817 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
133 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
1answer
459 views

Remix: Gas required exceeds allowance or always failing transaction

I have a contract which has transferFrom function mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping (address => bool) public ...
3
votes
1answer
651 views

Error Ganache: Run out of gas - Works in Remix/Not from dApp

I am working on an application that stores and retrieves personal data on/from the ethereum blockchain. Just working on this to improve my Solidity and SC expertise and get comfortable with the ...
3
votes
1answer
285 views

Geth Sync Problems | Rinkeby, Ropsten | Deploy contracts

Get Geth to sync --> Rinkeby test network. For the love of god I just want to deploy a contract. I have deployed it to Ganache-cli, GUI, remixIDE, deployed with truffle/Infuria.io...I keep failing to ...
3
votes
0answers
35 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
149 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 ...

1
2 3 4 5
39