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,619 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
69 views

Methods and constants order in the contract ABI

Is it possible to annotate methods and constants order in the contract ABI before compilation?
3
votes
1answer
203 views

Parse arbitrary bytes input

A function recives bytes as input: function foo (bytes data) How do I parse that into individual byte32 chunks? function foo (bytes data) returns (bytes32[]) My goal is to understand how to handle ...
3
votes
2answers
661 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 ...
3
votes
1answer
76 views

Non-specific error from truffle debugger

I am testing a contract which is using ecrecover function of solidity. While its testing when i go with a failed test case while debugging, it doesn't go step by step and at the end return the same ...
3
votes
1answer
315 views

Loop with optimal gas usage

I currently have the following loop (some stuff left out) mapping (address => uint) pendingWithdrawals; function example () private{ address[] tempList = List; for(uint k = 0; k < ...
3
votes
0answers
211 views

Benefits of library versus a plain contract (upgradeability)

I'm trying to find what the benefit is of a library. I found the following statements. (Please correct me if i'm wrong) Cost less gas to deploy Uses the storage of the calling contract the library ...
3
votes
3answers
410 views

Storage Pattern considering Gas cost

I was following Are there well-solved and simple storage patterns for Solidity? and ended up creating Mapped Structs with Delete-enabled Index to make sure that my array doesn't grow infinitely, when ...
3
votes
0answers
474 views

Why the transaction reverted?

Try to run my contract in remix JavaScriptVM and faced with error. Contract code: ... /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract ...
3
votes
2answers
289 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 ...
3
votes
0answers
503 views

Brew linkapps deprecated, unable to install on Mac

brew linkapps solidity Warning: brew linkapps has been deprecated and will eventually be removed! Unfortunately brew linkapps cannot behave nicely with e.g. Spotlight using either aliases or symlinks ...
3
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 ...
3
votes
2answers
321 views

how to avoid re-entrancy vulnerability warning?

Transfer amount to any address always showing the re-entrancy vulnerability warning. How to avoid this warning? function completeChallenge(address _challengerAddress,address _challengeAddress,uint ...
3
votes
1answer
277 views

Full Integration Testing smart contracts

What is the most agile way to fully integration test smart contract code? I've seen people use shell, etc. Is there a golden standard somewhere?
3
votes
0answers
560 views

ParserError: Source “contracts/Token.sol” not found: File import callback not supported

I have problem when I use truffle test. I seperated files used in contract with Solidity framework and I can't compile my code(see below). When code is not seperated works fine. I tried reinstall ...
3
votes
0answers
555 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 ...
3
votes
0answers
529 views

Why is the transaction hash (tx.hash) not available in Solidity?

Why not solidity provide tx.TxHash (only tx.gasprice , tx.origin)? reference https://solidity.readthedocs.io/en/develop/units-and-global-variables.html, tx.TxHash,Transaction(ID) Hash, it should be ...
3
votes
0answers
197 views

Contract creation from another contract succeeds, then fails?

I have a first contract with some very basic functionality : contract ContractA { uint public supplyA; function ContractA (uint _supply) { supplyA = _supply; } function ...
3
votes
0answers
188 views

What is the runtime performance of Ethereum Libraries compared to Contracts?

I'm looking for the cheapest way (in terms of gas price) to design upgradeable contracts. I don't expect many upgrades. Being inspired by Writing upgradable contracts in Solidity, I'm investigating ...
3
votes
0answers
116 views

Assuming EIP140, is remaining gas refunded when a called contract throws?

Under EIP140 (REVERT) and assuming Solidity ≥0.4.10. If I call from my contract to a function on an external contract, and this external function does an invalid jump, does my contract still call ...
3
votes
0answers
934 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" --...
3
votes
0answers
112 views

What is the fastest way to call a function for incoming ICO

We have Alarm Contract: http://docs.ethereum-alarm-clock.com/en/latest/ We have parity client-side scheduling: Parity - How to schedule a transaction? We can write custom contracts similar to this ...
3
votes
0answers
210 views

Checking if an address is encoded on the end of a bytes array

I have a bytes array. Within the last 20 bytes, there is an address stored. I am trying to compare the address at the end of this array to the address of a msg.sender, and am wondering if there is a ...
3
votes
2answers
736 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() ...
3
votes
0answers
196 views

Implement constant search function in Solidity or in Javascript?

I am working with Meteor + Web3. Is it recommendable to implement a constant search function in Solidity or to transfer the data into a javascript array each time to then search in it? Thank you!
3
votes
0answers
120 views

Is there any reference on writing contracts directly with the bytecode language?

It would be great to have a complete reference of all the opcodes available, their exact effects and costs, and an example "Hello World" in ethereum assembly. Edit: this question isn't a duplicate of ...
3
votes
0answers
87 views

Solidty Browser doesn't load properly

Solidity Browser doesn't load anymore. Here is a screenshot with the Chrome Developer open. on Chrome Version 52.0.2743.116 m It's stuck on loading and I see in developer some error messages. It ...
3
votes
0answers
96 views

Contribute function of crowdsale is not working

I am having a crowdsale contract. I am trying to run contribute function using command: contractInstance.contribute.sendTransaction(101,{from:eth.accounts[0],value:200, gas:4000000}). It is creating a ...
3
votes
0answers
138 views

How are strings coerced into uint?

I executed a call checkConstant("ein schnitzel") on the following contract, and it worked. Obviously, type coercion but the documentation doesn't tell. How does this happen in detail? contract X{ ...
3
votes
0answers
190 views

Secure unit conversion in Solidity

Let's say you want mint a token TOK that is pegged to the USD. Then following must hold: (1) TOKUSD = USDTOK = 1 (2) USDETH = 1/ETHUSD (3) TOKETH = 1/ETHTOK The formula of the exchange rate is TOKETH =...
3
votes
1answer
269 views

importing a contract does not access to its modifiers

Contract A imports Contract B and Contract B contains a modifier that I want to use in contract A. Contract A is set to inherit from Contract B, however I get the following when I try to use the ...
3
votes
0answers
527 views

Compile Smart Contract with Solidity on Windows 10

I wanted to use solidity within geth in Windows 10. I tried the compiled version that comes with Ethereum 1.0 but it has an issue mentioned in this thread. I'd like to get a new binary of a newer ...
3
votes
0answers
131 views

How to use an accessor for imbricated data types?

I'm looking at information about accessors in solidity/js for more complex data structures than just a public array/mapping. How can i access the array in that code for: struct AnotherStruct {....} ...
3
votes
1answer
72 views

What is the maximum computation a query or constant function in solidity can perform?

Since query or constant functions are just executed on single node there is no dependency on gas or gas limit. I am performing Quicksort in query/constant method. EVM can sort an array of length up to ...
3
votes
1answer
516 views

How do I connect to the Remix JavaScript VM from my front end

I have been developing using Remix and Metamask but it's a slow progress when pushing to the test networks. I have switched to the JS VM in Remix but I am not sure about how to connect my frontend to ...
3
votes
1answer
2k views

What is the burn() and burnFrom() function in EThereum Token Creation contract?

Please find the below ethereum token creation contract. It has two burn functions. It is having redendent params also. Why it is placed, what is the importance of the functions. pragma solidity ^0.4....
2
votes
0answers
24 views

How Can You Map a Struct Twice With Different Keys?

I have a struct mapped with an address as the key. I want to iterate through all values of that mapping with another key value, in this case a nonce that I generate in the contract. Is this possible? ...
2
votes
1answer
31 views

How does one retrieve revert/require error messages from RPC

In both of these questions, the user is asking if it's possible to get the error string from a revert or require. The answers say, basically, "Yes" and point to Truffle or other methods. VM Exception ...
2
votes
0answers
20 views

Increasing the difficulty/cost of manipulating an on-chain PRNG?

well, from what I understand since everything on-chain is deterministic so theoretically there's no way of having a real cryptograhically secure random number generator that cannot be manipulated by ...
2
votes
0answers
18 views

Name Styling Best Practices Internal/External variables/functions etc

The solidity docs clearly specify how to style function order, types etc. However, are there an appropriate way to also separate between internal/external variables, functions etc. I see some people ...
2
votes
0answers
32 views

Nested usage of interfaces?

Using solidity ^4.x, it seems I can use an interface as a parameter type in a function from a different interface. Example: interface IERC20 { function transfer() external; } import "./IERC20....
2
votes
1answer
30 views

Ethereum Blockchain Interoperability

I was reading through Vitalik's blockchain interoperability paper available here One thing he mentions is a company / project called EthereumLottery.io (currently not operating) which managed to ...
2
votes
1answer
75 views

Using 'call' from a constant function

I am trying to determine the behavior of call when executed from a constant function. Of course, the compiler issues a warning on that: Warning: Function declared as view, but this expression (...
2
votes
2answers
38 views

To transfer tokens from owner address to an address, if latter address moves some other tokens to a given particular address

I am writing a contract for an ERC20 token (say ABC). Is it possible to airdrop some of these newly minted ABC tokens to those ERC20 addresses, every time, if they transfer a different token (named ...
2
votes
1answer
31 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 ...
2
votes
0answers
55 views

How the following pairing equality be verified in Etherum Smart contracts?

I have found available precompiled contracts in solidity. For example, this answer enter link description here points out a precompiled contract that can verify BLS signature. However, looking to the ...
2
votes
1answer
36 views

bn256 and Boneh-Boyen digital signature in solidity

I am looking to have a full-fledged implementation of bn256 in solidity. And Boneh-Boyen digital signature. Is there is any available built-in libraries or implementation in solidity to bn256 and ...
2
votes
2answers
72 views

Metamask injects one account in web3, but calls contracts using another account

Building a React app, MetaMask injects web3, I get accounts[0] from getAccounts(), then pass it to my contract functions together with other parameters. I want my modifiers to lock incoming function ...
2
votes
1answer
33 views

Hashnot matching generated from solidity contract and web3js

I want to make hash same as generating by solidity contract from web3 or ether's js. In solidity contract hash generation by below : sha256(abi.encodePacked(no of parameters)). Kindly help for it. ...
2
votes
2answers
88 views

Best way to create identity contracts for organisations

What is the best way to create identity contracts for organisations based on their information like name, address, organisation type(buyer/seller) etc. I have tried using factory pattern to create ...
2
votes
0answers
112 views

Solidity get return variable from a send method in React

I'm trying to call a method that pushes data to my Blockchain and then returns back the ID of the new struct I created. This is how I'm calling the method in my React code: const documentId = await ...