Stack Exchange Network

Stack Exchange network consists of 174 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

100
votes
2answers
18k views

Are there well-solved and simple storage patterns for Solidity?

Simple and appropriate data organization can challenge Solidity newcomers. It wants us to organize everything in ways many of us aren’t accustomed to. Are there well-solved general patterns for ...
147
votes
11answers
28k 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 ...
83
votes
7answers
30k views

What is an ABI and why is it needed to interact with contracts?

ABI is referenced in many places including the official Ethereum website. What is an ABI and why is it necessary to use?
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;...
85
votes
5answers
25k views

How can an Ethereum contract get data from a website?

What is the process/workflow behind the process where an Ethereum contract gets some data from a website?
34
votes
8answers
17k 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?
61
votes
3answers
19k views

Difference between require and assert and the difference between revert and throw

I was looking at the docs and Im looking for clarification on the difference between require and assert and throw and revert. assert(bool condition): abort execution and revert state changes if ...
23
votes
4answers
7k views

What public test-networks and faucets exist?

What public test-networks exist and what are their conditions? What are the connection data? How often (if so) are they reset? Does a public faucet exist for this test network? Does a block explorer ...
18
votes
1answer
7k views

Deploy contract from contract in Solidity

It's a common pattern to use a hub/factory contract to create multiple instances of a standard contract. It's also common to require a way to enumerate the addresses of the created contracts. Is ...
45
votes
3answers
7k views

What is a recursive calling vulnerability?

What is a recursive calling vulnerability exactly? When creating smart contracts, DAOs or DAPPs, what measures can I take to ensure I am not vulnerable?
14
votes
1answer
2k views

How much computation can be done in a fallback function?

Simply sending Ether to a contract, will run the contract's code. In Solidity, this code maps to what it calls the fallback function. How much work can be done in a fallback function?
24
votes
4answers
5k views

Error while compiling: Stack too deep

When trying to compile, I am getting the following error: "Internal compiler error: Stack too deep, try removing local variables." Is there any way around this? I'm not sure if I'll be able to ...
19
votes
3answers
25k views

How to call my contract's function using sendTransaction

This may be a very basic question, I don't know why but I am unable to find correct solution to how can I call my contract's method using sendTransaction. I have a transfer(address, uint256) function ...
37
votes
3answers
14k views

What is the zero, empty or null value of a struct?

If I have a mapping of string => custom defined struct, how do I check if a value is defined in the mapping? The docs state that "every possible key exists and is mapped to a value whose byte-...
4
votes
2answers
3k views

Remix Warning - No visibility specified, Violate Checks-Effects-Interaction pattern, Function state mutability can be restricted to pure - Can ignore?

Two months ago, I wrote a smart contract with Remix.ethereum.org. Line 1 of my code has: pragma solidity ^0.4.11; It compiled fine with no errors and nor warnings. I tested every function in ...
25
votes
3answers
13k views

How to create a Dapp from scratch on Ethereum?

Let's say we have someone who knows about blockchain but who doesn't have any background in blockchain-based application. That person wants to code an ethereum-based Dapp (decentralized application) ...
21
votes
3answers
10k 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 ...
12
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!
18
votes
2answers
9k views

How can you call a payable function in another contract with arguments and send funds?

I have a contract named Call: contract Call { ... function () payable { // TODO: Call the call function in the main contract // and forward all funds (msg.value) sent to this contract ...
8
votes
3answers
2k views

How do you verify a contract on etherscan that is deployed by another contract?

How do you properly verify a contract on etherscan that is deployed by another contact? I deployed a contract that deploys other contracts onto the blockchain. The original contract is verified , ...
34
votes
5answers
22k views

How to delete an element at a certain index in an array?

Anyone know how to delete an element in a array? Is there any built in method to do that? If not, does anyone know of how to implement such a method?
13
votes
2answers
2k views

Can a contract access another contract's storage?

I have a contract with numerous complex structs. Is it possible for a second contract to iterate over this data directly? I can't really use public accessor/getter methods as it's not possible to use ...
33
votes
6answers
27k views

How do you get a json file (ABI) from a known contract address?

I want to watch a Solidity contract using the Mist browser. I know how to do that and it needs the address and the json. I have the address, but I don't have the json. I do have the source code. Can ...
20
votes
4answers
6k views

How to store IPFS hash using bytes?

Following Q/A (What datatype should I use for an IPFS address hash?) recommend us to use bytes to store IPFS hash. I was using following example(https://github.com/AdrianClv/ethereum-ipfs/blob/master/...
22
votes
3answers
16k views

Returning a struct and reading via Web3

I am storing data in my contract using a mapping of structs. For examples sake, say I'm storing employee info (name/address/salary), mapped by their employee ID. Via a web front-end, I'd like to be ...
27
votes
5answers
17k views

How to concatenate strings in solidity?

I'm trying to concatenate two strings in solidity. I tried with + or . but neither option works. There is not much documentation on string concatenation yet. Is it even possible? If not, can I ...
28
votes
2answers
19k views

Use string type or bytes32?

What are the benefits to using string datatypes over bytes32 to represent text data. It seems my contract runs into an out of gas exception when I switch the data structures from bytes32 to string.
13
votes
1answer
1k views

How do I get the storage indices/keys?

I would like to explore the storage data of a contract. I have geth fully synched and I interact with it over RPC. There is the function "eth.getStorageAt(addr, index, block)" provided, but you need ...
6
votes
2answers
3k views

Syntax for calling contract state changing methods

I've been struggling a bit with calling methods that change the state of the contract. Take, for example, the following contract: contract C { uint[] numbers; function initNumbers() { ...
6
votes
1answer
1k views

Store secret data in contract [duplicate]

I know about the general open / trustless protocol of storing transactions. How would I approach a scenario here where I want to store some data in a contract on deployment, to later be retrieved by ...
14
votes
5answers
30k 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 ...
37
votes
2answers
22k views

What is an Event?

What is an Event? Are they only used in Solidity? How are events defined? How are events initiated? Is there a standard term for an event's invocation (do you say an event "happened", "was called",...
18
votes
2answers
3k views

Explanation of Parity Library Suicide

So today, A vulnerability found within the Parity walletLibrary which resulted in freezings of potentially hundreds of millions of dollars from wallets using parity multi-sig. Can someone technically ...
13
votes
1answer
3k views

Deploying contract with constructor arguments via Geth RPC

How can I deploy a compiled contract with constructor arguments using geth rpc? I have tested my call deployed the compiled contract bytecode just fine, I just don't understand how I can pass ...
9
votes
5answers
5k views

How to convert an address to bytes in Solidity?

What is the recommended way to convert an address to bytes in Solidity?
8
votes
3answers
8k views

Best way to burn ethers and other ethereum tokens?

Is it correct that any ethers or tokens sent to the address 0x0000000000000000000000000000000000000000 will be destroyed? Or what is the best way of burning ethers / tokens?
14
votes
5answers
3k views

How do I know when I've run out of gas programmatically?

This keeps coming up on the gitter forums so I thought I'd ask and answer this question: How do you know when you've run out of gas?
10
votes
1answer
1k views

How to read a private variable from a contract?

Given a contract, how can I find out the current value of one of its variables (as a dev, not from the context of another contract), if it's not public?
9
votes
2answers
4k views

What are the contract languages?

Besides Solidity and Serpent, what are the other (experimental) contract programming languages?
0
votes
1answer
591 views

“UPDATED : ” “VM Exception while processing transaction: revert”

I tested signature verification of the code presented HERE as follows: running testRPC : root@ubuntu:/home/s# testrpc EthereumJS TestRPC v6.0.3 (ganache-core: 2.0.2) Available Accounts =============...
18
votes
2answers
2k views

Methodological security review of a smart contract

Is there a tool, checklist of methodology to help reviewing smart contract security? E.g. for each of function you review Is there re-entry possibility and how it behaves on re-entry How it behaves ...
29
votes
2answers
18k views

Solidity, create contract from contract

Based on documentation it should be possible to create new contract from contract contractAddress = new OwnedToken(name); When I invoke this method from contract, the address I receive seems to be ...
28
votes
8answers
12k 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?
30
votes
5answers
14k views

How can I debug a smart contract?

When developing my smart contract, how can I debug it? Are there any debugging, testing tools or simulators that I can use to examine my code?
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) ...
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)...
10
votes
2answers
2k views

isContract function using EVM assembly to get the address' code size

My problem is that I need to make sure my contract processes only the transactions coming from EOA (externally owned accounts). For this I need to determine the type of account I'm dealing with. In ...
7
votes
1answer
6k views

What's a fallback function when using address.send(…)?

This code is in my contract: contract A { address x = 0x1234...; x.send(10); } What would fallback function in the contract at address 0x1234... look like? contract B { ... } ...
6
votes
1answer
9k views

What does Solidity's “call” function mean?

address nameReg = 0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2; nameReg.call("register", "MyName"); //1 nameReg.call(bytes4(sha3("fun(uint256)")), a); //2 if(!nameReg.call.value(10)){throw;} //3 Here ...
14
votes
3answers
2k views

Accessing past values of Smart Contract variables

I would like to know if is possible to inquiry variable values using older blocks. For example I have contract Simple { string32 message public; function Simple() { message = msg....