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,741 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
99 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
131 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
311 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 ...
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
226 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
1answer
249 views

How to use evm compile?

I have been testing with evm and I am not getting any output. Code - pragma solidity ^0.4.18; contract d8 { function myBalance() pure public returns (uint) { return 880; } } My ...
3
votes
1answer
77 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
347 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
222 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
0answers
163 views

What's the difference between unlinked_binary and bytecode?

I have two different projects. In one, the build/token.json file contains an unlinked_binary field. In the other, there's no unlinked_binary, but there's bytecode. What's the difference between the ...
3
votes
3answers
439 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
486 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
0answers
519 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
2answers
339 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
312 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
1answer
224 views

error: invalid opcode using modifier

Im getting the following error when trying to run my js test file using truffle: Error: VM Exception while executing eth_call: invalid opcode The js test file is the following: var DebitService = ...
3
votes
0answers
630 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
592 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
579 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
198 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
193 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
118 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
114 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
217 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
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
122 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
97 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
193 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
280 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
543 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
78 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
551 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
25 views

Solidity Contract and Library difference

I am learning to program Solidity and just playing around with it in remix. I am creating compiling the following code in Solidity: pragma solidity >=0.4.22 <0.6.0; contract Ballot { ...
2
votes
0answers
26 views

In solc 0.4.x assembly, how can I check if a non-constant function returns 'bool' or nothing?

I know how to do it for a constant function, for example: pragma solidity 0.4.25; contract Callee0 {function func() external pure returns (bool) {return false;}} contract Callee1 {function func() ...
2
votes
0answers
22 views

Web3 Ethereum log subscriptions - removed field?

I am trying to subscribe to Ethereum events (via Infura) but I'm a bit confused. I am following this documentation: https://web3js.readthedocs.io/en/v1.2.0/web3-eth-subscribe.html#subscribe-logs ...
2
votes
1answer
40 views

Modifying simple function with inline assembly

I'm trying to write a super simple contract that's gas efficient utilizing inline assembly in solidity. All this function needs to do is create a child smart contract with one function, self destruct....
2
votes
0answers
24 views

Performing a C-like pointer increment in Solidity

I have a memory or calldata struct with an attribute of type byte[]. I want to have a memory variable with that data, except for the first n Bytes. In C, you'd just write typename variablename = ...
2
votes
0answers
20 views

Is there any particular reason the position of the public/private keywords change depending on whether it's a function or variable?

I fear it will be difficult for me to remember if this quirk of the language is arbitrary...
2
votes
0answers
33 views

Ethereum Smart Contracts/dApp’s open source license?

Can a smart contract in which it’s source was released be GPLv3/GNU licensed? I.e. if a company were to release the source code to a smart contract, can that smart contracts source code be GPLv3/GNU ...
2
votes
0answers
46 views

Combine two addresses into one

I want Solidity code to define a function f that would map two Ethereum addresses A, B into a new address X = f(A,B) such that there is nearly zero probability that X is an already taken address (an ...
2
votes
0answers
26 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
92 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
22 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
23 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
34 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
102 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 (...

1 2 3 4 5 35