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
0
votes
1answer
180 views

Custom token transfer, what am I doing wrong?

I am trying to hash an address then send tokens to a mapping of the hash in the token contract, then be able to withdraw those tokens using a hash of the address. It compiles but cannot make it work. ...
0
votes
0answers
544 views

Contract forwarding ether transfer

I'd like to have a contract A which upon being sent ether, it transfers the ether to contract B, which upon receiving an eth transfer executes some logic. Is there a way to do this without contract A ...
0
votes
0answers
262 views

Obtaining Gas and Gas Price Solidity

I added the following two lines of code to my function: uint gas_remaining = msg.gas; //irrelevant code.... refund = refund + ((gas_remaining - msg.gas) * tx.gasprice); For some reason this is ...
0
votes
1answer
327 views

“Error: VM Exception while executing eth_call: invalid opcode” when accessing array

I'm trying to incorporate storage in a smart contract where participants of the contract will have their address stored in a address[] look up table participationAddressLUT. The contract initializes ...
0
votes
1answer
78 views

Can not see Solidity events

I can see events in a private net, but when I connect to "real" net, I can not see them. Meaning .watch(function(err, result) is never called. My theory is I am using lightning, and it probably means ...
0
votes
2answers
328 views

Parse Error before Event definition in solidity

pragma solidity ^0.4.0; import "github.com/oraclize/ethereum-api/oraclizeAPI.sol"; contract DieselPrice is usingOraclize { function DieselPrice(){ event one(string description); ...
0
votes
0answers
274 views

Format of return value from a function

I have this function from a Solidity contract. SomeStruct public rr; function getRatingResult() public constant returns(bytes32) { // rr is an instance of a struct variable that has a field ...
0
votes
1answer
171 views

Passing data to a method

I am working on a smart contract that take a data from each node to be stored in the blockchain What is the best data structure to pass it as a method parameter?. I have done a string but it doesn't ...
0
votes
3answers
891 views

How to link Standard Token with crowdsale in Zeppelin Solidity

Hello I am trying to create a crowdsale through zeppelin solidity but the main issue is it doesn't provide a way to link standard token with pre-allocated supply with the crowdsale. pragma solidity ^...
0
votes
1answer
72 views

Can't execute funtion second time

pragma solidity ^0.4.16; interface token { function mintToken(address receiver, uint amount); } contract Owned { address owner; /*this function is executed at initialization and sets ...
0
votes
2answers
153 views

Problem with smart contract deployment

I have compiled test crowdsale smart contract with inheriting from other contracts( like TestToken is MintableToken). The main smart contract consists only of one file, where I described all ...
0
votes
1answer
170 views

can't call createtokens function in my ico contract, help

I'm trying to prepare an ico for my friends association, I'm using Basic Attention Token's source code. I'm trying to call the createtokens function in the contract to create the coins but I can't ...
0
votes
1answer
41 views

ERC20 coin generation delay

We were trying to generate the new coin using ERC20 cook book approach. We are not deviating from the instruction. We tried different cases with Mytoken, etc. We have been presented with spinning ...
0
votes
1answer
474 views

Smart contract external function with dynamic array of bytes32[] as argument works only from Remix

Here is my full contract's code. The reason I ask here is the function startNewBallot(). As you can see, it accepts bytes32[] dynamical array pragma solidity ^0.4.8; contract ibaVoter { struct ...
0
votes
1answer
295 views

Javascript to display multiple records from a struct

I am trying to build some Javascript using Web3js to list out nested structs. Specifically, I have designed a customer struct through a mapping. I have nested in the customer struct two additional ...
0
votes
1answer
142 views

Missing Token Contract Address

Two months ago, I wrote solidity contracts on remix.ethereum.org. They compiled and ran fine. This code, which you can see here https://gist.github.com/anonymous/1b5c669c09683f285d44c36ab40555dd , ...
0
votes
0answers
100 views

Using modifier on view function works locally, but fails on Ropsten

Hey I'm trying to make it inconvenient to view stored data in a contract, but it seems that the function is returning null values when I add a modifier. The modifier makes sure someone is approved ...
0
votes
2answers
217 views

Reading parameters from Smart Contract

I have a Crowdsale smart contract taken from the example provided by Ethereum on their website. The Crowdsale contract contains the addresses of the people who participated in the Crowdsale. Is there ...
0
votes
2answers
519 views

Events with string argument not working (not indexed)

I am trying to listen to an event on rinkeby test which I run locally. Every thing works fine when my argument is int such as event EventTester(int values); When I change the event argument to string ...
0
votes
2answers
397 views

How to detect what instruction caused “truffle test” to result in “invalid opcode” error?

I wrote a test for my contract and it returns invalid opcode as a result. Full output: 1) Contract: FPCoin1 One can purchase tokens for ether: Error: VM Exception while processing transaction: ...
0
votes
1answer
198 views

Error while calling function in smart contract using nodejs?

I have deployed a contract in private blockchain using mist wallet. When I try to call the function in the smart contract using web3 api it through the below error /home/karthikeyan/Desktop/n2/...
0
votes
0answers
120 views

can't get transfer to execute

I am trying to run the following solidity function: function test() payable { msg.sender.transfer((balances[msg.sender]/1000)*this.balance); } Where this.balance is 0.1 Ether and balances[msg.sender]...
0
votes
2answers
648 views

Mist stuck not downloading last 100 blocks

My mist wallet won't download the final blocks it needs to be fully synced to the blockchain. I have 0.18 ether in my account which is visible on etherscan, but it won't show on Mist. Is getting ...
0
votes
1answer
36 views

How can i know my smart contract , compilar version.I cant verify my contract properly

I want to know compilar version of my smart contract.(https://i.stack.imgur.com/6K5sM.png)
0
votes
1answer
104 views

Problems funding Ethereum Wallet

Tried making three separate transactions from two separate wallets (Coinme and Coinbase) each in relatively small amounts (less than $50) to fund my Ethereum Wallet 8.0 for Mac. None have appeared ...
0
votes
1answer
145 views

Unable to change contract data with nodejs (web3)

I created a contract, and deployed it into my private blockchain, as you can see I use mapping and dynamically allocated array. When I am trying to add a domain by 'addDomain' method with remix web ...
0
votes
0answers
597 views

totalSupply in ERC20Basic contract is not initialized to zero. Does that matter?

I copied code from TenX, which copied code from OpenZeppelin. TenX and OpenZeppelin has this code for contract ERC20Basic: contract ERC20Basic { uint256 public totalSupply; function balanceOf(...
0
votes
1answer
114 views

Browsing a mapping variable

This is my contract where I am building a list of members who will use a addVote function. The allMembersVoted function always seems to return false even though the Remix debugger shows that, the ...
0
votes
0answers
245 views

Invalid opcode during division

I have seen many posts around the division operation in Solidity e.g. Cant' do any integer division. Firstly, the error I am facing is different. Secondly, I am ensuring that, all numbers in division ...
0
votes
1answer
2k views

invalid address error on running code - solidity

Here is my code : var Web3 = require('web3'); var fs = require("fs"); var Artifactor = require("truffle-artifactor"); var provider = new Web3.providers.HttpProvider("http://localhost:8545"); var ...
0
votes
2answers
1k views

How to calculate an Ethereum Contract's address during its creation using the Solidity language?

Now I know and have read the other thread saying that a contract's address is created deterministically via RLP encoding the creator's address and his nonce and then hashed with Keccak-256 but the ...
0
votes
0answers
461 views

returning struct in solidity

I have seen here that we can return struct for internal functions. Why can we return struct for non-internal function? Also, I can see in the same link "structs would have to be integrated into the ...
0
votes
1answer
67 views

Time-Currency Tokens

How would you go about creating a token that has a value based on time? (Time-currency Tokens) What would be the solidity code be? I can't find much examples on this. Thanks.!
0
votes
1answer
84 views

Question about how to have interacting contracts

Let's say I'm doing a crowdsale, but instead of selling a set amount of tokens I'm just giving tokens away at a pre-set price. In other words, my token has the following functoin: function give(...
0
votes
1answer
270 views

Modifiers misunderstanding

pragma solidity ^0.4.0; contract test { bool test_bool1 = false; bool test_bool2 = true; modifier test_modifier(bool _test_bool){ if (_test_bool == false) throw; _; } ...
0
votes
0answers
620 views

Solidity "Error: Invalid type for argument in function call. Invalid

This error doesn't make sense Error: Invalid type for argument in function call. Invalid implicit conversion from function (bytes memory) external to function (bytes memory) external requested.
0
votes
2answers
34 views

ParserError: Expected pragma, import directive or contract /interface/library definition

In an attempt to compile my ABI and verify my contract, I am getting the following warning: "ParserError: Expected pragma, import directive or contract /interface/library definition" on the first line ...
0
votes
3answers
33 views

condition check of struct mapping in solidity?

struct User { string username; string password; address userid; bool isAdmin; } mapping (uint => User) users; function checkIfUserExists(address userid) public ...
0
votes
1answer
29 views

Get deployed contract details from Private network in all connected Peers

I have created one Ethereum private network and added two nodes inside that n/w. I have migrate one contract using truffle in that n/w from one node. Now I want to access that contract inside ...
0
votes
1answer
18 views

create Tookens problem

For some time I have been writing my own tooken. I call it COIN I come across the last three problems: my fallback function does not work code: function () payable { createTookens (); he ...
0
votes
3answers
711 views

How to get events result using web3 1.0.0 version

function depositToEscrow(bytes32 _id) public payable returns(uint) { DepositToEscrow(msg.sender,orderdata[_id].buyer,msg.value,orderdata[_id].amount); } suppose this is my function in a smart ...
0
votes
1answer
555 views

use metamask to send eth to many adresses

i want to use metamask / myetherwallet and not mist because of sync problemems to send token to 100 addresse i have this code (solidity) but i dont know how to implement it please help me link ...
0
votes
1answer
1k views

Please provide example for web3.currentProvider

The following document states that "MetaMask is going to continue to inject the ethereum provider as web3.currentProvider for the forseeable future.": https://github.com/MetaMask/faq/blob/master/...
0
votes
3answers
68 views

mapping one id to multiple addresses

Suppose I have a product with a specific id for sale(so I am the owner) and someone wants to buy the product from me. When he pays the price he will become the new owner of that product. How can I ...
0
votes
1answer
67 views

Parent-Child Contract Synergy Broken

When I call a function from a child contract which has been generated through a parent contract, then the mapping within the parent contract which consist of information related to the child contract (...
-1
votes
0answers
18 views

How to select a wallet address by the token number he owns?

I need to allocate a winner among the token holders. I want to keep the concept that the more tokens someone buys the more chance there will be that he will be the winner. now lets say 960 tokens ...
-1
votes
1answer
31 views

Smart contract to strore and retrieve address and ID in blockchian using mapping

I want to store some address and their ids in blockchain using mapping and i want to know how to get the stored addresses when searching with their respective IDs.
-1
votes
1answer
43 views

Problem retrieving array of struct with web3js

I'm trying to return the struct values contained in array everytime i push a button thet call inserimento and ritornavalore functions. here is my code in solidity: pragma solidity ^0.5.1; pragma ...
-1
votes
1answer
307 views

How to concatenate string array into a single string

I am trying to concatenate a whole array of string into a single array for printing purpose. function getArray() public view returns (string) { arr.push("Max"); arr.push("good"); arr....
-1
votes
1answer
257 views

How to diagnose “invalid opcode” when compiling?

I have a huge contract so isolating the cause will be very arduous manually. Is there any way to get an indication automatically of what might be causing an "invalid opcode" error?