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,747 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
526 views

Importing files from an “outside” folder

I am trying to import files from a relative path outside of my Truffle-project folder: import '../../../common/solidity/contracts/token/ERC20/BurnableToken.sol'; import '../../../common/solidity/...
2
votes
0answers
427 views

Working with time in smart contracts

I know there have been quite a few questions surrounding time, and the use of block.timestamp. However, I still have a few questions design-wise. At what point exactly is it 'dangerous' to use block....
2
votes
0answers
44 views

Where does Ethereum Dapps go in known design paterns

I am doing a Dapp for a school project and I am supposed to choose a design pattern to work with. I want to know the possibilities for design patterns concerning the ethereum dapps, or if they have ...
2
votes
0answers
135 views

how to wrap data for transferAndCall to invoke another contract?

I have a token, and a service contract. I implemented the token based on ERC677, and tried to use transferAndCall to call my service contract. In my service contract, there will be several methods ...
2
votes
0answers
364 views

truffle assert equal not accurate for small differences

For some reason my truffle test suite "should send coin correctly" passes when it shouldn't. I'm just running a test suite on the standard ERC20 code found on ethereum.org. When you take 1e+21 -1010, ...
2
votes
0answers
216 views

Arabic letters not read by web3.toUtf8

I am using arab letters in bytes32 data stored in a smart contract, when reading the data and converting to utf-8 with web3.toUtf8() i get errors like unknown utf character or Invalid continuation ...
2
votes
0answers
277 views

transfer function is not working for the smart contract

Below is the Scenario of the problem: I made some changes in the real concept because it will hard to understand the problem so I try to make it real simple. I make a contract to facilitate some ...
2
votes
0answers
94 views

Using smaller parent contract consumes less gas?

Here's my Test Code pragma solidity ^0.4.20; // StandardToken is from zepplin-solidity. import "./StandardToken.sol"; contract Callee { address public caller_; function setCaller() public ...
2
votes
0answers
342 views

How to set dynamic buy and sell price for my token?

I have built a simple erc-20 token. I used the code given on ethereum.org code as a reference. There they have talked about setting the price of my token. But how do I set it dynamically, as in ...
2
votes
1answer
163 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
279 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
1answer
339 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
287 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
957 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
154 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
200 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
262 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
174 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
114 views

Solidity IDE Parser Error on Token Name

Getting this in Solidity: browser/ballot.sol:121:16: Parser Error: Expected Primary Expression. Here is my code, says that it is the name line with the parser error function ERC20Token( ) { ...
2
votes
1answer
167 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
292 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
115 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
91 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
541 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
382 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
2answers
496 views

Ethereum Solidity Contracts w/ Fiat Money

Is there anyway to fix a price for a ERC20 token? It seems like a major problem with blockchain and crypto is all of the volatility, which is why I am hesitant to use it for applications even though ...
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
134 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
87 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
654 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
315 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
168 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
514 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
97 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
213 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
106 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
257 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
407 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
632 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
270 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
48 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
0answers
458 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
322 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
76 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
133 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
384 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 ...

1 3 4 5 6 7 35