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

28
votes
1answer
21k views

How to Initialize a Struct?

I have a struct like so : struct fooStruct { uint foo; uint figther; } I would like to initialize that struct but it won't be stored in a mapping but inside an array. Is there a way to ...
6
votes
1answer
1k views

How does a fallback function rejecting ether work?

A contract in Solidity can have a fallback function like: // This contract rejects any Ether sent to it. It is good // practise to include such a function for every contract // in order not to loose ...
7
votes
1answer
1k views

Who pays gas when a contract function that creates/calls another contract is called?

If I call a function of Contract1, that creates/calls another Contract2. Who pays the gas used to call Contract2 ? I think it's Contract1 - the second msg.sender. In that case, how can I make the ...
6
votes
1answer
177 views

Why do some functions from my contract end up in the ABI while others don't?

Using the greeter example, The original contracts is written with 4 methods: mortal(), kill(), greeter(), and greet(). Why then when I look at the mined contract does it show me an ABI of: { ...
13
votes
1answer
9k views

Mapping with array as Key Or Value data type

Is it possible to do a mapping with an Array as key/value ? Where an array would exist for each value ? I'm actually looking to store structs in a mapping but can't seem to have it work. Struct Foo{...
5
votes
1answer
719 views

Can you input decimals number in smart contract?

I'm having an issue where send 0.1 or 1.1 is saved as 0 and 1 in my contract's storage. Does anyone knows how to properly pass decimals ?
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 ...
12
votes
4answers
2k views

How can I get a list of of transaction data which are sent to a specific contract?

I'd like to get a list of all transactions which are sent to specific contract or method of contract. What kind of way do we have to implement it?
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 ...
4
votes
0answers
565 views

Why are underscores used in front of parameters, instead of contract member variables? [duplicate]

In Solidity, for example, why: function Greeter(string _greeting) public { greeting = _greeting; } instead of: function Greeter(string greeting) public { _greeting = greeting; } The latter ...
3
votes
2answers
409 views

Can I use my own coin in 3rd party contracts?

I know you can create your own coins in ethereum but can they be used in 3rd party contracts that normally use ether?
15
votes
2answers
3k views

What is the purpose of underscores in front of parameters?

I see contracts that use underscores in front of parameter names, like so: function Greeter(string _greeting) public { greeting = _greeting; } What's the purpose of these underscores? Do they ...
3
votes
2answers
250 views

From the solidity SubCurrency example: return statements

Obviously this is rookie question, however I do not believe Solidity docs, nor W3Schools explicitly state this. In the return statement, is the second line in the block equivalent to a second Then ...
3
votes
1answer
125 views

How can the global registrar be called from a contract?

I want to call what i would do in geth with registrar.owner(namevar) from a solidity contract. Is this possible - and how?
4
votes
2answers
634 views

Is it safe and effective to use 128 bit integers to track wei in a contract in order to save gas?

The default type for Wei in Solidity is the 256 bit unsigned integer. (e.g. msg.value) However, to track 1.7e38 wei (1.7e20 ether) you only need a 127 bit integer. That's a gigantic number not ...
5
votes
1answer
842 views

What is BlockApps and how can it be used with Ethereum?

BlockApps says: Customized, permissioned private Blockchain ledger to your specifications. Based on Turing-complete Ethereum standards, your Blockchain has full Smart Contract support built-in. ...
7
votes
2answers
3k views

How can ethereum be used to send messages between connected machines?

I want to know how I can send messages between accounts and contracts. The idea is that I have three Raspberry Pi devices. Each one is connected to an object (the first to a temperature sensor, the ...
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?
5
votes
4answers
788 views

What is Etherparty?

Etherparty is a platform that removes the complexity and management of creating and executing smart contracts. What exactly does that mean, and how does that work?
4
votes
1answer
138 views

What is the C-Like Language CLL?

There are some older projects, dated back to 2014 which develop contracts in CLL, C-Like Language. What is this and is this still being developed/used?
9
votes
2answers
5k views

How to concatenate a bytes32[] array to a string?

I am passing an array of bytes32 to my function. This array can contain numbers or hashes etc. to identify an object. In a new use case I want to pass a URL to this function by splitting the URL into ...
3
votes
3answers
2k views

What is the best language to start programming in Ethereum?

I have an introduction to C++ under my belt (very simple stuff), and other skills like an occasional R script, that's about it. Where should I go from 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....
5
votes
3answers
2k views

How to compare msg.data (calldata) data type to an integer data type uint256?

As per my question here: I need to compare msg.data (specifically, numbers that are sent with the sendTransaction data object) to a data type of uint256 within my contract. How is this possible?
4
votes
1answer
825 views

If statement doesn't hit certain conditions

I'm currently working on a very simple(first project) market in solidity and i'm having an issue with a piece of code : contract smallMarket{ struct transaction { uint timeStamp; ...
9
votes
2answers
1k views

How to pass struct mappings to solidity functions?

I have two mappings (uint => customStruct) called listA and listB. I want to run both through a single function to perform operations on the contents. How do I pass this type into a function so ...
5
votes
3answers
348 views

Are smart contracts unique to Ethereum?

Is that why ethereum is considered to have a lot of potential? In other words, what does ethereum offer that other blockchain technologies can't replicate.
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?
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-...
6
votes
1answer
567 views

Can you do a POST to an external webform using a Ethereum smart contract?

Can you do POST or submit a form from an external site using a smart contract? And how can this be done? Are there any examples of live code out there?
6
votes
2answers
3k views

How to manipulate data in a Solidity smart contract?

I have a smart contract with some members which should get modified on certain events. For simplicity, let's imagine we have a greeter contract. If I call greeter.greet() in the JavaScript console, ...
2
votes
2answers
2k views

Attaching an address for a contract to call another contract

I am writing code where I want to call other contracts within my current contract. Bank.sol contract Bank { address owner; mapping (address => uint) balances; function init() ...
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 ...
3
votes
1answer
234 views

What is an 'uDApp'?

The online solidity compiler offers an output of smart contracts labelled uDApp, for example the greeter uDApp looks like that: [{"name":"greeter","interface":"[{\"constant\":false,\"inputs\":[],\"...
11
votes
2answers
2k views

What's the difference between developer mode and testnet?

I just tried running geth in developer mode on testnet. ~ $ geth --dev --testnet F0127 21:07:16.947591 6407 flags.go:467] dev and testnet are mutually exclusive I wasn't aware of the actual ...
21
votes
1answer
1k views

How does the solidity optimizer work?

The compiler for solidity supports the flag --optimize which performs some set of optimizations to the compiled solidity code, typically resulting in a reduction of gas costs. How does the optimizer ...
16
votes
2answers
13k views

How can I return multiple strings from a contract function?

In solidity it's obvious how to get a single string returned from a function. But, I'd like to have the smart contract return multiple string values. Is there a way to do this?
23
votes
2answers
8k views

'internal' keyword in a function definition in Solidity

Does the internal keyword in a function definition such as: function doSomeThing(uint _param) internal {...} work similar to designating a method as private in other languages and thus makes the ...
9
votes
3answers
194 views

Repository and packaging standard for open-source smart-contract modules

Is there a standard way to package the source code of a smart contract and publish it on a public repository? In such a way to enable structured reuse, with versioning and easy ways to update an ...
2
votes
1answer
53 views

What are common pitfalls when coding in Serpent?

Some pitfalls for coding in Solidity are here and what kind of pitfalls are there in Serpent? (This is not related to Python, which is covered here)
4
votes
1answer
545 views

Is Mutan still used as language?

Mutan was designed by Jeffrey Wilcke as a Go-like language for contract development. Is it being used and developed / maintained?
9
votes
2answers
4k views

What are the contract languages?

Besides Solidity and Serpent, what are the other (experimental) contract programming languages?
10
votes
2answers
3k views

Is LLL still used as language?

What is the state of the contract programming language LLL (Lisp-Like Language)? Is it still used and supported?
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?
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?
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) ...
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 ...
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?