Hot answers tagged

28

Via a Framework There are currently four primary frameworks available that can facilitate writing unit tests for your contracts. Listed in order of Github stars as of 2016-01-25. Disclaimer: I'm the author of the Populus testing library. Embark website: https://iurimatias.github.io/embark-framework/ written in: javascript tests: javascript via Mocha ...


16

Update Apr 23 2017 geth 1.6.0 has a breaking change to remove access to the Solidity compiler from within geth. The workaround is detailed in How to compile Solidity contracts within geth with the v1.6.0 **BREAKING CHANGE**? Update Feb 04 2017 Solidity 0.4.9 has a breaking change. The workaround is detailed in Unable to define greeterContract in the ...


14

There is no semantic difference. It is a style used to differentiate between function arguments and global variables. In this case, it differentiates between the global variable named greeting and the corresponding function parameter.


13

In most situations the storage variable is going to be used in many more places throughout the contract's code. The function argument may show up in a few places, but in most cases it won't be as prevalent as the storage variable. It is this developer's opinion that it is nicer to work with greeter than _greeter. In my code the function argument gets the ...


13

Seems like the contract address should be enough. You're right, it would be better if the ABI could be obtained by just looking at the contract. So why do contract writers need to also provide the ABI, in addition to the contract address? One reason is that the function Method IDs in a contract are computed using a hash function. So it is infeasible for ...


11

You don't need the source code, just the ABI. The ABI is produced when the code is compiled, but can be, and usually is, distributed separately. The ABI is essentially just a list of the function names in a contract and what types of arguments they take. You don't even need the whole ABI, just the parts that you want to interact with. For example, to ...


8

Update Apr 23 2017 geth 1.6.0 has a breaking change to remove access to the Solidity compiler from within geth. The workaround is detailed in How to compile Solidity contracts within geth with the v1.6.0 **BREAKING CHANGE**? Note: Solidity 0.4.9 has a breaking change to a lot of old examples The new Solidity 0.4.9 3 days ago mentions that you have to be "...


8

My advice would be to use the Browser Solidity: Just copy paste your contract, and if it compiles without errors you can just copy past the content of Web3 deploy: var _numProposals = /* var of type uint8 here */ ; var ballotContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"type":"...


6

greeter and mortal are constructors, and like in other languages, only callable once, during instantiation.


5

You're correct, this is no longer the case: Many of the planned Frontier gotchas (which included a chain reset at Homestead, limiting mining rewards to 10%, and centralized checkpointing) were deemed unnecessary. source I'm not exactly sure why they thought this was necessary, but I think the idea was that if major changes to the EVM needed to be ...


4

I totally follow this guide, but I still did not get the info" contract mined! address: xxx". I add a else{ console.log(e) into var greeter = greeterContract.new(_greeting,{from: eth.accounts[0], data: greeterCompiled.greeter.code, gas: 4000000}, function(e, contract){ if(!e) { if(!contract.address) { console.log("Contract transaction send: ...


4

The Greeter tutorial page on the official site clearly states how to run the kill method under the "Cleaning up after yourself" section. greeter.kill.sendTransaction({from:eth.accounts[0]})


3

Nothing disapears, if you have mined your contract (deployed in the blockchain) as in the mentioned tutorial you need to have its address to call it anytime you want. in the tuto you have : var _greeting = “hello world” ; var greeterContract = web3.eth.contract(…..); var greeter = greeterContract.new( so you creates the contracts and you get back its ...


3

I posted this question a week ago and with the help of my peers i was able to solve it. The detailed answer is as follows: Step 1: Using the following command start your private blockchain network( change the data directories and other parameters according to your custom settings) geth --identity "node1" --rpc --rpcport "8000" --rpccorsdomain "*" --...


3

Heres a javascript command that will strip newlines xmlStr = xmlStr .replace(/\n/gi, ""); // strip newlines


2

I think you meant to say that your account has ether in it, not ethereum. My first guess is that you don't have enough ether. Try web3.fromWei(eth.getBalance(eth.coinbase),'ether') You might need something like 0.001 ether (just a guesstimate) to deploy your contract successfully. When you deploy, you will get a transaction hash, which is a lot ...


2

A uDApp is short for Universal DApp and is described as "A Universal Interface for contracts on the Ethereum blockchain". As the project hasn't been maintained for 5 months and the demo is currently broken (Reference and Type errors if you open Javascript console), it's hard to picture what it would have done. My guess is it would have shown the different ...


2

Here's a step-by-step guide of deploying and running Greeter on Testnet. I you do not already have a coinbase account, run the following command: user@Kumquat:~$ geth --testnet account new Your new account is locked with a password. Please give a password. Do not forget this password. Passphrase: Repeat Passphrase: Address: {...


2

There are still more breaking changes in the newest Solidity. I used the following to fix my error in 0.4.9 latest commit. You need to copy the filename from the compiled code. In my example, this is /tmp/geth-compile-solidity311107485. Then use this in the next step. See screenshots. The command to use is: greeterCompiled["/tmp/geth-compile-...


1

Just adding the answer from the above comments, so that this question can be closed: sudo pip install --upgrade populus should solve this problem. Although no one is likely to have this specific issue anymore.


1

From this video: https://www.youtube.com/watch?v=8jI1TuEaTro I discovered Truffle (https://github.com/trufflesuite/truffle) Couple of things on life cycle: The contract creator pays gas to get the contract into the block chain. If the method or access is constant, the client and do the operation. Constant operations do not modify the block chain, so ...


1

Generally there will be one node which initiates the contract. and when it is mined, the contract would be added to the blockchain which returns a contract address. The peer nodes which are interested in the contract, must know two things that needs to be shared. the contract address the contract abi with the help of this two the other peer nodes could ...


1

Welcome to Ethereum - a world of dragons and tools that constantly outpace any documentation. I would suggest that you start playing with smart contracts (e.g. the greeter) only in the browser using Remix. You can copy-paste the greeter example into the browser editor and play with your smart contract there. Everything will only run in your browser but ...


1

Variable declarations will return undefined. Its not an error. In order to get contract address you need to mine in your private network. Make sure that your are mining.


1

I think I found what was the problem: lack of double quotes. When instantiating the Smart Contract using the literal ABI from https://ethereum.github.io/browser-solidity/ everything works! > var greeter = eth.contract([{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"greet","...


1

That callback is being called twice, the first time when you send the creation contract transaction and the second when the contract is actually mined and has an address (when the else fires in the callback function). You must wait to the logs to appear stating your contract has been mined and has an address. The tutorial says you should wait like a minute, ...


1

Because you did not add it. greeter.at("0xXXXXXXXX") Where XXXX is the address displayed in the console. Then, the greeter will have an address. If you missed the message in the console, you can still retrieve it by querying the transaction. If you don't know the transaction address, you should examine the account's address. You can do it from the ...


1

Please refer to Deploying the Greeter contract via the geth CLI is not registering in my private blockchain for a step-by-step guide for running the greeter example in your local dev blockchain. The commands and the expected outputs in the Window #2 sections in the link above should be very similar in the live network. And the undefined messages are ...


1

I have just added a step-by-step example of running the greeter example documented in Deploying the Greeter contract via the geth CLI is not registering in my private blockchain . This guide provides you with the commands to run and shows you the expected outputs at each step so you can confirm that you are running the Greeter example correctly.


1

Did you mine? If you're running a private network, another thing some people forget to do as well is to actually mine on the network for the transaction to be processed. So if you're on geth just miner.start()


Only top voted, non community-wiki answers of a minimum length are eligible