Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [contract-development]

Questions regarding the development of smart contracts

22
votes
3answers
11k views

How can I represent decimal values in Solidity?

I just started writing some solidity and I noticed that there are no decimal values such as double or float. What do you guys do when you need to return send to a wallet let's say 1.57 ether? Or when ...
5
votes
1answer
81 views

Implementing a card game, how to keep the dealt cards secure?

Hello I am a novice with ethereum and encryption... If i would implement a cardgame in ethereum, i jave to deal cards to users. I think this can be done by encrypting the cards by the players' public ...
3
votes
2answers
717 views

When sending a transaction to a contract does the sender beforehand know the ID that will be assigned to the transaction?

I need some ("Proof-able fair") randomization inside a contract, I was thinking of using the Transaction ID, but can the client before sending the contract know what the Transaction ID is going to be?
2
votes
2answers
585 views

What programs should a beginner solidity developers use?

At this time I write code in the 'Solidity realtime ethereum compiler and runtime' chrome extension. And I test my codes on the main net. Are there better programs or how can I get test ether?
3
votes
2answers
2k views

How do you get events from a function in another contract?

I have two contracts : // contract #1 contract eXample { // intizializer function eXample{ ..... } //creating the Event event MyEvent(uint x,uint y,uint z); function doSomething{ ........
14
votes
5answers
31k views

Where can I find some Solidity / Smart Contract source code examples? [closed]

Is there an easy to access list of Solidity / Smart Contracts / Dapps source code examples? Related information: Is there a list of DAPPS that are already useable? Where can I learn how to develop ...
9
votes
1answer
3k views

Finding and Using Solidity Libraries (ie. Math functions)

How do I find and use any existing Solidity libraries like you might in Javascript? For example, Math functions: How do I implement the equivalent of Math.sqrt(x) in a solidity function? Related: ...
4
votes
1answer
231 views

How to simulate out of gas events on a private blockchain?

I want to get the error message "Intrinsic gas too low" during a eth.sendTransaction call. Is it possible to simulate the condition of having run out of gas in a private blockchain scenario? Can ...
17
votes
4answers
9k views

How does one contract send ether to another contract with more than 2300 gas?

I want one contract to collect a certain amount of finney before sending it to another contract, but I can't simply send in with C2.send(thisMuch). function() { Dividend m = Dividend(dividendAddr)...
34
votes
8answers
18k views

How to quickly test a Solidity function?

There are snippets and functions of Solidity code provided on this Ethereum Stack Exchange and other sites. What are ways to quickly test them, possibly debug a little, and play around?
8
votes
1answer
974 views

Check if msg.value is even?

I'm trying to check whether the amount send by an account is even. For now, I have the code below but when I send only 1 ETH, it doesn't not come back. Seems odd (pun intended :p ) uint amount; ...
4
votes
1answer
728 views

How do I access a contract by its address (within Mix)

I am trying to use Mix to test multiple instances of the same contract, therefore I am trying to select a contract by address, but currently without success. Is this a limitation within Mix or my ...
6
votes
1answer
236 views

Architecture best practices for decentralized, multi-seller sales platform

My question revolves around contracts creating subcontracts, and best practices with contract creation. The Story: I'm creating a tool to help people buy Widgets, Gizmos and Ratchets, all of which ...
8
votes
3answers
3k views

How can I accept Bitcoin payment in a smart contract? What would be the code for that?

I will create my personal token and I would like to be able to sell it for ETH and BTC. I know how to add the sell function for ETH, but how can I sell the tokens for BTC? The ETH sell function I ...
9
votes
1answer
6k views

Is it possible to have mappings inside mappings?

Is this possible? mapping(address => mapping(uint => customStruct[])) someName Because I cannot debug and find my mistake... is there not enough gas, or it crashes on this code, while trying ...
6
votes
2answers
2k views

Smart contract based betting

Let’s say I want to enter into a bet with my friend that if it rains 10 days from now, I will pay him $100. If it doesn’t, he will pay me $100. Would it be possible to take advantage of smart ...
7
votes
2answers
2k views

What is the purpose of tokenRecipient contract in token example?

The example of how to create a token (https://www.ethereum.org/token) includes contract tokenRecipient. Why is it there?
5
votes
1answer
3k views

How to create a data structure in Solidity with no limits on size?

In solidity we are not allowed recursive Structs, so I cannot create a recursive data structure with unlimited nodes. Similarly, Solidity Arrays are fixed to the size you initialize them with. So I ...
4
votes
2answers
1k views

truffle deploy to geth failing, generating “receipt not found” repeatedly from geth

I've just installed truffle on an ubuntu virtualbox, and it is failing to deploy to a geth dev setup. Geth gives me a never-ending receipt not found for transaction ...
7
votes
4answers
491 views

Splice Struct Entry by Index in Solidity

I have a struct and I'd like to remove an item by index: struct Payout { address addr; uint yield; } Payout[] public payouts; I'm not familiar with structs and more use to dealing with arrays ...
6
votes
2answers
2k views

Can smart contracts compute on encrypted data?

There's a ton of super technical articles out there published about this, but I cannot understand them because I don't have a PHD in cryptography. So then, put simply, can I or can I not have smart ...
19
votes
2answers
2k views

Private info in an Ethereum smart contract

Is there any way to store info on a smart contract, and keep it a secret? If a contract has a state variable that is not public like: contract foo{ uint public publicVariable; uint notPublic;...
8
votes
1answer
2k views

Constructor auto generation and property visibility

Suppose I have the folloing: contract Owned { address owner; function owned() { owner = msg.sender; } modifier onlyOwner() { if (msg.sender == owner) _ } } ...
9
votes
2answers
3k views

constant versus public in solidity functions

Using Mix, if I create a contract in the scenario with address A as a parameter, clicking on getConstant in the html below returns A as I would expected it, and I see a JS flagged transaction. If now ...
19
votes
2answers
9k views

Is there a way to find an account's current transaction nonce?

I need to know my transaction nonce because I am doing fancy stuff with contract addresses (which are the keccak hash of my address + my transaction nonce). Is there a way to find this through the ...
6
votes
1answer
257 views

Deploying new contract in transaction MIX IDE

I'm running into an issue whenever i try to create a new transaction with my newly created contract "richoCoin". It seems like its expecting the "Sample.sample()" contract. How do I resolve this?
9
votes
2answers
1k views

Check if Contract variable is undefined

How can I check if an Contract variable is undefined in Solidity?
10
votes
3answers
9k views

Visual Studio Code Ethereum tutorial

Are there any tutorials on how to use MS Visual Studio Code to write contracts in solidity?
6
votes
1answer
626 views

Can I retrieve the timestamp the contract was mined on, inside of the contract?

I'm aware of the now keyword that aliases block.timestamp (uint): current block timestamp and the time units But I fail on finding a way to get the block timestamp of when the contract was mined. ...
9
votes
3answers
2k views

How can I create complex array relationships in solidity?

Hello I'm trying to work out how to create complex relationships in Solidity. In this example a customer will place an order using a function with arguments, however it cannot be for any combination ...
149
votes
11answers
29k views

Upgradeable smart contracts

If the contract issuer wants to have a way to upgrade the contract code, so that account data and other things carry over, can Ethereum provide for this? Also can this be done without changing the ...
5
votes
1answer
202 views

Can a user send a transaction using my website frontend with an account which is not in my node?

Can a user send a transaction using my website frontend with an account which is not in my node? The solution to this problem could be create an account for every user in my platform, but I think ...
4
votes
1answer
440 views

How to reference coin contract already onchain?

In this tutorial: https://dappsforbeginners.wordpress.com/tutorials/interactions-between-contracts/ they talk about interactions between contracts. However, the metacoin contract appears to be in the ...
2
votes
0answers
136 views

Using External API in a Contract? [duplicate]

Is it possible (and feasible) to have a solidity contract connect to an external api and execute a contract based on what is found? For example betting on sports games by agreeing to a credible API ...
3
votes
2answers
375 views

Mix IDE Tutorial error: index.html - line 15 - Uncaught TypeError: Cannot read property 'contract' of undefined

I got the following JS error: JavaScript error: index.html - line 15 - Uncaught TypeError: Cannot read property 'contract' of undefined whenever I tried to enter a name and a rating in store ...
7
votes
1answer
93 views

Is Coin a reserved word?

If I try to compile the following example code in Mix it doesn't work. As soon as I change the name from Coin to Coins it starts working as supposed? Is this a bug or a feature? contract Coin { //...
5
votes
2answers
942 views

Using a contract multiple times with multiple people

Just a question for my understanding. Let's say I have a contract that has two people involved (for example, a buyer and a seller). Through ethereum, is it possible to re-use this contract and use an ...
7
votes
1answer
402 views

How do I plan for an upgrade on my contract? [duplicate]

Absolute beginner question: If I assume that my contract is complex and will need future features or bugfixes, and that it holds assets and records privileged addresses, how should I prepare for an ...
3
votes
1answer
428 views

How do I make a Dapp that orders pizza?

So I recently purchased ether.pizza with the intention of setting it up so people can order pizza with ether just to use as an experiment in Dapp and contract development. Initially I plan on just ...
23
votes
1answer
8k views

Cannot perform write functions in smart contract - invalid address?

I have the following simple smart contract... contract SimpleStorage { uint storedData; function set(uint x) { storedData = x; } function get() constant returns (uint retVal) ...
13
votes
1answer
3k views

How to make external contract function calls from one contract to another?

I'm having a hard time understanding the documentation for making an external function call from one contract to another. In this tutorial there is an example: contract InfoFeed { function info() ...
28
votes
8answers
13k views

What are the development tools for Ethereum?

Could someone make a list with development tools for Ethereum together with a short description what they are good for?
10
votes
2answers
3k views

Is it possible to call Ethereum API from a Software Application without running an ETH node?

I was wondering if it's possible to make a call to Ethereum blockchain from a software application on my computer without having to run an ethereum node ? for example, I want to make calls from a ...
2
votes
1answer
417 views

Pass an array along when a contract creates a new contract

Can an array be passed along as a contract creates a new contract ? Specifically, an array of addresses. address[] verifiedUsers; new generatePOItokens(verifiedUsers);
5
votes
1answer
131 views

Using strings in a Serpent contract

In the limited documentation on Serpent, it mentions the ability to use a str type as both input and output to a contract function. Short strings are converted to numbers and longer text uses the ...
2
votes
1answer
77 views

Contracts with custom fee and limited numbers of transactions

Is there a valid way to set custom re-sell fee for "custom currency", e.g. https://blog.ethereum.org/2015/12/03/how-to-build-your-own-cryptocurrency/ and limit this re-sells somehow? For example: 0. ...
8
votes
1answer
823 views

Can a contract access the code of another contract?

Using web3.js, the EVM (bytecode) of a contract can be obtained by web3.eth.getCode(addressOfContract). Can this be performed by a contract using the address of another contract? If so, how? ...
13
votes
2answers
3k views

Can a contract listen to events of another contract?

I read that to listen to events you need to use web3.js. Are there other ways of doing it? Can a contract even somehow listen to events of another contract? Thanks!
1
vote
1answer
96 views

Contract functions not triggered

My contract deployed on address 0x63788a3eace0d77c5573787e3f9c9515c246d0e6 Is not getting executed via Mist browser. I have tried execute NewPoll function that requires 4 fields text 32 bytes I ...
8
votes
2answers
806 views

Is there a comprehensive reference list of all Solidity commands?

Is there a comprehensive reference list of all Solidity commands?