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,626 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
156 views

Indexed arguments can't be retrieved, why?

Indexed arguments will not be stored themselves. You can only search for the values, but it is impossible to retrieve the values themselves. This is a quote from the following docs: http://...
2
votes
1answer
269 views

Revert on non-fungible token, when sending external call from second contract

Thanks for your time. I'm working with a Non-fungible token. I am trying to call the non-fungible token contract from a second contract called agContract. I can create and track the owners of the ...
2
votes
0answers
149 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 ...
2
votes
1answer
322 views

Update struct from function only if parameters exists

What's the appropriate way to update a struct via a function only if the parameters exist? For example struct MyStruct { bytes32 someThing bytes32 someOtherThing } function updateStruct(bytes32 ...
2
votes
0answers
48 views

Why would a contract throw after it has executed the last line of code?

I'm debugging a contract function with Truffle. It always throws the following error: Error: VM Exception while processing transaction: revert However, I'm certain that the function has reached the ...
2
votes
1answer
273 views

How can I use solc solidity compiler on truffle webpack?

When I try to import solc, it raises an error which says: ERROR in ./~/require-from-string/index.js Module not found: Error: Can't resolve 'module' in 'C:\users\bisrat\Desktop\webpacksample\...
2
votes
1answer
932 views

How to call & use ERC20 airdrop smartcontract

I'm using remix solidity browser compiler. I deployed this code for an AirDrop smart contract: https://pastebin.com/kzYxmEab I used the same address to create/deploy the Airdrop contract as was used ...
2
votes
0answers
153 views

Call several endpoints in an Oraclize nested query and return an array

I am trying to get an average of ETH/USD conversion rate through Oraclize. My query works well when calling one single HTTP endpoint but I would like to call several endpoints within the same query ...
2
votes
0answers
199 views

How to create a contract B that calls a library via contract A

As I understand it, the logic to deploy contract that uses library is as below: supposed that MetaCoin contract use TestLib library Deploy TestLib library first, then get a library contract address ...
2
votes
1answer
252 views

If a function calls another contract function that throws, will the initial function throw as well?

If I call a function in another contract that doesn't return a boolean, but has throw() invariant checks, is it safe to assume the function finished properly if the transaction isn't reverted? I ask ...
2
votes
0answers
172 views

Can the behaviour of the Ropsten Test net be compared to that of the main net?

can be assumed, that a contract behaves in the same way on the Ropsten Test test as well as on the main net, in terms of gas consumption for example? (I think, that the gas price might be different?) ...
2
votes
1answer
157 views

Library function access-level

I have a contract A, which has an instance of contract B, i.e., B b. Contract A calls a function of contract B via the instance, i.e., b.func(). Contract B is stateless, i.e., no global non-constant ...
2
votes
0answers
281 views

Solidity - check PoW difficulty

If given block data and a difficulty number, is it possible to verify that the header produced is at or above the provided difficulty from within Solidity? For example, suppose I have the following ...
2
votes
0answers
112 views

Is there any good reason in having a stateless contract?

If I understand correctly, then any stateless contract can be re-declared as a library. Is there any advantage or benefit in keeping it as a contract? If there is any, then I guess it would be in ...
2
votes
0answers
90 views

Interfaces and gas savings

Does it save gas to link to the bytecode of an interface? I tested this is solidity remix and using the interface to link bytecode instead of the full contract, didn't seem to reduce any gas costs for ...
2
votes
1answer
533 views

Fail to “buy” from Crowdsale contract wrapping an already deployed contract

Hi I am a newbie to the Ethereum development. I have successfully deployed a burnable, pausable, capped token contract (TC) on rinkeby test network, and was able to interact with it - minted and ...
2
votes
0answers
360 views

undefined contract address when trying to deploy with web3 and Metamask

I am trying to develop a simple wallet type contract but having troubles deploying it. I am trying to deploy it using the method described here. I am using truffle and web3 along with Metamask. Now, ...
2
votes
0answers
73 views

Is it possible for a mapping to run out of space?

Can storage mappings in a contract run out of space? Say that mapping was keyed to an address and the value as the following struct: User bytes32 name uint8 age Theoretically, if there was a ...
2
votes
0answers
129 views

Transactions Mined Status in Go Lang

I have a private block chain setup. I am calling a smart contract method from Go Lang. I my code in GoLang should wait until the transaction got mined. How I can achieve that. Regards AKM
2
votes
0answers
86 views

What's the value of `this` inside a library function when called via a delegatecall?

Imagine a contract C that makes a delegatecall to a library L. C -> L What's the value of this inside L: address(C) or address(L) ? If now that L makes a normal call to another contract D. C ->...
2
votes
0answers
622 views

Struct variable of type enum not getting updated

I am trying to update a struct variable of type enum contract BookStore { enum BookStatus { Open, Sold, Unsold } mapping(uint => Book) stores; uint public count; struct Book{ uint bookId; ...
2
votes
1answer
307 views

Error: VM Exception while processing transaction: invalid opcode at transfer function

I try test function transfer in my contract. I following by tutorial. Full project locate on my git. It is my test.js code: var SPT = artifacts.require("StepanToken2"); contract("Testing ERC20 ...
2
votes
0answers
154 views

Remix/Android wallet app?

Is it possible to create an ethereum smart contract using remix from the browser of your android device and then linking it to your android ether wallet app without using a PC anywhere along the token ...
2
votes
1answer
494 views

How to call the functions of Ethereum Smart Contract from Android/iOS application?

I've been learning solidity & viper for some time now but i am wondering if it's possible to call the functions/methods of a smart contract (already deployed on Ethereum Network) from an Android/...
2
votes
2answers
96 views

Is Solidity creating an implicit getter for a nested contract that is created?

Is Solidity creating an implicit getter or not for a nested contract that is created? Example: contract Foo { .... } contract Bar { Foo public foo; Bar() { foo = new Foo(); } ...
2
votes
1answer
210 views

Contract creating other contract doesn't show resulting transaction details on etherescan

Looking for help with a successful transaction not showing the details on etherescan. Having a deployed factory contract like so (simplified): contract EntityFactory { event EntityCreated(...
2
votes
0answers
101 views

Good centralized data storage for Solidity types?

I'm looking for a good database client that operates well on uint256 and bytes32 mainly. I can hack around this in postgres, but I'm wondering if there are any more obvious solutions?
2
votes
0answers
241 views

Where is the attack contract used for the dao attack?

I studied The DAO attack. I want to see attack contract. but I found just child dao(0x304a554a310C7e546dfe434669C62820b7D83490) Reentrant attack is needed fallback function. How can I find the ...
2
votes
0answers
393 views

Send transaction with metamask and web3

I'm new to the topic but can I somehow sendTransaction via contract instance? What I'm missing here? I simply want to send some ether to contract. var abi =[ { "constant": true, "...
2
votes
1answer
533 views

Truffle Bytecode Different from Etherscan Bytecode

I am having difficulty verifying my contract code on Etherscan using the code generated by Truffle. Using Etherscan VerifyContract V1: https://rinkeby.etherscan.io/verifyContract Truffle produced ...
2
votes
1answer
262 views

Can we call two contracts in web3.eth.filter method?

I have two contract address and I want to check events on both in one call. I mean, can we pass two contract address in one option param like i do below? let web3 = new Web3(); web3.setProvider(...
2
votes
0answers
47 views

Adding default accounts with ETH in populus?

I'm thumbing through populus docs, and I don't see anything about adding additional default accounts preloaded with ETH into the test chain? I see I can set defaultAccount and/or web3.eth.coinbase, ...
2
votes
1answer
215 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 = ...
2
votes
0answers
450 views

Do we have to have a fallback function in our smart contract?

I have a smart contract that has only one payable function and one that pays, as follows: contract DAO_Test{ // define something function buyToken() payable external returns(bool){ ...
2
votes
0answers
298 views

Transaction history of accounts for a contract

I want to get the transaction history of the transactions that have been performed by the accounts using my contract (on a private blockchain). If I perform transactions using the eth.sendTransaction(...
2
votes
0answers
70 views

A simple toggle function

I am busy teaching myself how to write smart contracts in solidity. pragma solidity 0.4.13; I am writing a simple toggle state method and this is how I would do it in PHP: function ...
2
votes
0answers
368 views

How to send ether from one account to another in a smart contract deployed on testrpc

I'm interested in writing a smart contract using solidity that sends ether from one account to another. What would the syntax be? If possible, could you point me to a solidity contract that sends ...
2
votes
0answers
132 views

Is there a “gas penalty” for using too many asserts in a contract?

I'm at a very puzzling scenario. While using Remix, I noticed that adding a few asserts has caused a significant increase in execution cost (from ~50K to ~59K). And not only did it increase the ...
2
votes
3answers
3k views

How to do an air drop to all ETH token holders?

Say I have an ERC20 token and I want to distribute it 1:1 to all ETH token holders at a given block. Is there a straight forward way to make a smart contract that anyone could call in order to receive ...
2
votes
3answers
1k views

Error: Invalid number of arguments to Solidity function | when trying to pass in parameter from App.js to Solidity

I am trying to call a function in my Solidity file (Coder.sol), while passing through a parameter from my App.js file. My function in my App.js file looks like this: handleStartRequirement: function(...
2
votes
0answers
381 views

Contract state and variable changes in pending transactions

I have a simple contract: pragma solidity ^0.4.0; contract Festival { address owner; uint8 max; address[] entered; function Festival(uint8 _max) { max = _max; owner ...
2
votes
0answers
137 views

Read function returning blank array in geth

I have deployed a smart contract on geth which has 2 simple read, write functions in it. Then I called the write function; e.g. payment.place_order("Laptop", 10,{from:eth.accounts[0]}). After the ...
2
votes
2answers
194 views

Writing a file and linking to blockchain

I've found parts of a smart contract and I have an idea how to add things but I'm currently stuck. Maybe you can help me with that. The contract looks as following: pragma solidity 0.4.15; contract ...
2
votes
0answers
589 views

Using delegatecall to forward eth

The following code snippet is designed to forward all funds to a single destination, but where multiple contract D's will exist, allowing differentiation of the original source of the funds. pragma ...
2
votes
0answers
223 views

Strange revert() behavior on Etherscan

I am testing my contract, which is for an auction. I've deployed it on the Rinkeby testnet. I have a payable function that calls revert() if the bid being placed isn't higher than the existing bid. ...
2
votes
0answers
239 views

what does the UnimplementedFeatureError mean?

I'm getting the following error in remix.UnimplementedFeatureError: Non-padded store for function not implemented.
2
votes
0answers
323 views

Remix debugger stops at external function call from another contract with Invalid opcode error

So I have token contract pragma solidity ^0.4.11; contract owned { address public owner; function owned() { owner = msg.sender; } modifier onlyOwner { if (msg....
2
votes
2answers
471 views

Deploying a contract that calls a contract

What is best practice on deploying a contract called within another contract with web3.js? I have previously gone under the assumption that the contracts must be mined separately, and the caller must ...
2
votes
0answers
213 views

How to parse method signature from msg.data in Solidity

I need to parse method signature from msg.data in Solidity. To understand what method are calling in msg.data. So I need to understand that f.e user call transfer method in passed data sha3('transfer(...
2
votes
0answers
133 views

Very big fee for token on testnet

I'm new here and try to make my own token. I kinda made it actually, but fee for it is very big(cheapest one is 0.65 eth). Here's my code: pragma solidity ^0.4.13; library SafeMath { function mul(...