ethereum setup private blockchain

Hands on Blockchain – One Day Class HANDS ON BLOCKCHAIN – ONE DAY CLASS Blockchain technology came into existence with the Bitcoin white paper by Satoshi Nakamoto in late 2008 as a means to enable peer to peer electronic cash transactions.Since then, the blockchain technology has evolved to allow a multitude of use cases beyond payments, including the digitization of assets, transactional security, and identity.It is being tested for applications in far ranging industries such as finance, legal, IP rights, and energy.Objectives This seminar is a hands-on 1 day blockchain class.Participants will learn how to spin up blockchain nodes (Ethereum and Hyperledger Fabric blockchain), create a private/permissioned network, and be able to create, deploy and interact with smart contracts.Class Outline: Day 1 Morning 9am-12pm 1.Overview of blockchain technology 2.Smart contracts basics, successes and pitfalls 5.Learn how to set up a private blockchain 6.

Each Student will setup an Ethereum blockchain node infrastructure on the Azure servers 7.Each student will then create their own tokens 8.After validating for a few blocks, exchange pre-created tokens within the nodes Afternoon 1:30pm-4:30pm 1.Each Student will setup a blockchain node infrastructure on the IBM Bluemix servers 2.Each student will then create their own tokens using the ‘marbles demo’ 3.Teams formed to create a blockchain use case 4.Design the DAO and DAPP or structure required 5.Code a simple prototype, or create slideware to pitch it 6.Pitch and demonstrate your prototype Learning Outcomes: At the end of the class, students should be able to: 1.Get an architectural overview of a blockchain 2.Deploy a private network 3.Understand the creation of Smart Contracts 4.Issue a token on the networks 5.Understand the basic structure of a smart contract Prerequisites: 1.Laptop with internet connection 2.

Familiarity with Github 3.Sign up for a free account with Microsoft Azure (directions will be given pre-class) 4.Sign up for a free account with IBM Bluemix (directions will be given pre-class) 5.Some programming language experience in any language (should know what things like functions or loops are) 6.
circle bitcoin walletDocker installed on their laptops/computers Costs: • Please contact for more information.
bitcoin ticker appLocation: • Client’s Facilities [/register” width=”100%” height=”500″] CLOSE var $dialog = $(‘ ‘) .html(‘‘) .dialog({ autoOpen: false, modal: true, height: 625, width: 500, title: “Some title” }); $dialog.dialog(‘open’); CLOSE
bitcoin casino affiliate programs

Is the blockchain a revolution?The technology that powers Bitcoin sure has the potential to disrupt the entire Internet, as we explained in a previous post.But how can you, a developer, use the blockchain to build applications?
bitcoin scratch cardAre the tools easy to use, despite the complexity of the underlying concepts?
bitcoin atm map ukHow good is the developer experience?
bitcoin fork mayWe wanted to find out, and there is no better tutorial than developing an app from scratch.
buy bitcoin with xrpSo we’ve made a simple decentralized ad server called Zero Dollar Homepage, powered by blockchain.
ethereum taxesThis is the story of our experience.
bitcoin atm anonymous

Read on to learn how hard the blockchain is for developers today.The blockchain shines when it replaces intermediaries.We chose to focus on Ad Platforms, which are intermediaries between announcers (who buy visibility) and content providers (who sell screen real estate).Our project was to build a decentralized ad platform running on the blockchain.Since the famous Million Dollar Homepage experiment, innovating in the field of paid ads can’t make you rich anymore.Instead, we chose to build a tool that allows to display ads for free - a Zero Dollar Homepage.For free, but not for nothing: advertisers exchange ad visibility for open-source contributions.So we’ve built a decentralized app to manage how ads display on a particular page.Advertisers need to take up a coding challenge to be able to put their ads on this page.In concrete terms, whenever we merge a Pull Request (PR) on one of marmelab’s open-source repositories, a GitHub bot comments on the PR, and invites the PR author to publish their ad on the ad platform admin panel.

Following the link contained in the comment, the PR author is asked to sign in with their GitHub credentials.Then, they can upload an ad - in fact, a simple image.This image is added to the list of images uploaded by other PR authors, in chronological order./ZeroDollarHomepage/ for the next 24 hours.Note: The entire process requires no intermediary, but in order to avoid the display of adult imagery on our site, we validate the uploaded images through the Google Vision API before putting them online.Here is how we separated responsibilities in each of the 4 use cases of an ad platform: This might seem surprising, as the blockchain plays a very small part in the process.But we quickly realized that the entire code of the ad platform couldn’t live in the blockchain.In fact, blockchains have very limited capabilities in terms of connectivity to the Internet, and processing power.So we delegated only the crucial ad placement tasks to the blockchain: Other tasks ended up in the admin app, outside of the blockchain, for various reasons: As we explained in a previous post, they aren’t many good choices when choosing a blockchain network.

So we chose Ethereum.We quickly hit our first wall.Until a few weeks ago, you couldn’t play with the Ethereum blockchain without buying Ether first, even for simple tests.Also, Ethereum didn’t really allow private blockchains in its former version (named Frontier), which made development very complicated.Anyone accessing the Ethereum network might call your test contracts.More importantly, the documentation is a volunteer initiative, and was not in sync with the development state.Note: Ethereum bumped their version since we developed the application, switching from Frontier to Homestead.The Ethereum community improved the documentation quality for Homestead.Despite these shortcomings, we managed to register three nodes on the Ethereum network across Nancy, Paris and Dijon, and to share a ping between those nodes.In the course of our documentation search, we eventually found the Eris documentation.Eris did an excellent job at explaining Blockchains and contracts.Moreover, they especially built a layer on top of Ethereum, and open-sourced a bunch of tools to ease the process of developing smart contracts.

eris is command line tool you can use to initialize any number of local blockchains you need.A smart contract is very similar to an API.It has a few public functions which might be called by anyone registered on the blockchain network.Unlike an API, a smart contract cannot call external web APIs (a blockchain is a closed ecosystem).A smart contract may however call other smart contracts, provided it knows their address.As with an API, the public functions are only the tip of the iceberg.A contract might be in fact composed of many private functions, variables, etc.Smart contracts are hosted in the blockchain in an Ethereum-specific binary format, executable by the Ethereum Virtual Machine.Several languages and compilers are available to write contracts: At marmelab, we code a lot in Javascript, so we chose to use Solidity.Solidity contracts are stored in .sol files.The Zero Dollar Homepage contract stores the claimed pull-requests, and a queue of requests to display.The first version of the Solidity contract looked like this: { = ; { , , , , , , } { ; ; ; ; ; } ( ) ; ; ; ; ; ; { = .; = 0; = 0; = 0; } { (.

( } } ( , , ) ( , ) { ( 0) { = (.; } ([ ) { = (.; } (( 0) { = (.; } 1; [ = ; [ = ; [ = ; [ = ; .(= + ( * 1 } () { ( 0) { (.} [[ = ; [0 1; = + 1; (.} ( , , , , ) { ( 0) { = (.; } = [[ = .; = .; = .; = .; = (.} } For this first attempt, we used the Eris JS libraries to communicate with our blockchain.Instanciating a contract from a Node.js file turned up to be as simple as: ; (, ) { = = = .(,} And calling it wasn’t difficult either: * (, , ) { = (, [, ] = .(,( 0) { (( } .} For more information about the Eris JS binding libraries, please refer to Eris documentation.We love Test Driven Development, and one of the first question we had was: how can we test a Solidity smart contract?The Eris guys made a tool for that, too: sol-unit.It runs a new local blockchain network for each test, in a docker container (which ensures each test run in a clean environment), and executes the test.

Tests are written as a contract, too.Well, not so fast.sol-unit is an npm package, and to use the testing functions (assertions, etc.), we had to import the contract supplied by this package in our testing contracts.For that, there is a simple Solidity syntax: So far so good… or not.We hit a strange case when compiling our contracts.Apparently, you can’t import contracts with such a path.We ended up adding a command in our test makefile target to copy those sol-unit contracts in the same folder as ours.After that, running sol-unit was simple and we started coding.: @cp -f ./node_modules/sol-unit/contracts/src/* ./src/ethereum/ : solc --bin --abi -o ./src/ethereum ./src/ethereum/ZeroDollarHomePage.sol ./src/ethereum/ZeroDollarHomePageTest.sol : ./node_modules/.bin/solunit --dir ./src/ethereum Running a blockchain and deploying our contract to it was as simple as following the Eris documentation.We managed to resolve the few troubles we met using a bunch of commands that we integrated in our makefile.

The whole process of running a new blockchain with our contract looks like this: After a few days of work, we were able to run the contracts on a local Eris blockchain.At this point, we wanted to try out our contracts on a local Ethereum blockchain.To communicate with contracts inside the Ethereum blockchain, we had to use the Web3 libraries.We learned a lot while trying to use them.We realized that eris was hiding a lot of the underlying complexity.First, our initial assumption that a contract is similar to an API was not correct.We had to distinguish functions that were only reading data from the blockchain, and functions that were writing data to it.The first kind (read-only functions) would return the resulting data asynchronously, just like an API would do.The second kind (write functions) would only return a transaction hash.The expected side effects of a write function (changes inside the blockchain) wouldn’t be effective until the corresponding blocks would be mined, which could take some time (from ten seconds to one minute in the worst case).

Moreover, we haven’t been able to make those writing functions return values, so we had to change our solidity code to call a write function first, then call a read function to get the results.We also discovered events, which can be used to be notified when something happens in a smart contract.The smart contract is responsible for triggering the events.They look like this with solidity: ( , And they can be triggered from any of the smart contract functions, like this: Those events are stored permanently in the blockchain.That means we could use the blockchain as an event store.It might be the easiest way to determine if a call to a function has been successfully executed: the smart contract may trigger an event at the end of its process with failure reasons, results of computation, etc… It’s worth noting that some integration packages for Meteor are already available.Eventually, we refactored our smart contracts to be a lot simpler in order to get almost the same features.

We had to get rid of the mappings (which we haven’t been able to use - our transactions weren’t mined by the Ethereum network for some reason).The solidity language may be close to JavaScript, it is still very young and incomplete.Arrays don’t have the functions we’re used to work with in JavaScript (not even indexOf), and strings don’t have any functions.This might be addressed by some community efforts in the near future.The Ethereum implementation looks like this: { ( ( , , ( , ; ; ; ; { = .; = ; = 0; } { (.( } } ( ) { ( 0) { ( ; } = ; = 0; (!{ ([] ) { = ; } { ; } } () { (, ( - ) * 1 , > ; } .(- ) * 1 } { ( < .- 1) { 1; } = ; } ( ) { ( .){ 0; } [ } } The process for claiming a pull request and returning the estimated display date evolved to become: ..(,

{ : .., (, ) { () { ; } (, ) .(0) { ( } = [0 (.) { ... } (.) { = ..; (..)) { ( } And with this code, our decentralized app worked in a local Ethereum network.Running our application in a local environment was a challenge, but deploying it to production, in the real Ethereum network, was a battle.There are a few gotchas to be aware of.The most important one is that contracts are immutable in code.This means that: Another gotcha is that every contract deployment and write operation in the blockchain costs a variable amount of ether.We managed to get 5 ETH (more about getting ether below), but we had no idea how much we would need to deploy our contract, or calling a transaction.It’s harder to test when each failed test costs money.For the Node.js part, we decided to run it on an AWS EC2 instance, like most of our projects.To do so, we had to: Make sure your blockchain node server has plenty of storage.

The current size of the blockchain is about 15GB.The default volume size on an EC2 instance is 8GB (sigh).We had many troubles because we hadn’t downloaded the entire chain (but we didn’t realize it immediately).For instance, we had an account with 5 ETH, but for a long time the system responded as if we hadn’t unlocked our account, or as if we had no ether.Downloading the rest of the chain fixed this issue.Likewise, unlocking our precious account containing 5 ETH was not an easy task.We did not want to hardcode our passphrase in the application, and we wanted to run the node with supervisord to ease the deployment.We finally found a way that allowed us to change the configuration without exposing our passphrase with the following supervisord configuration: [program:geth] command=geth --ipcdisable --rpc --fast --unlock 0 --password /path/to/our/password/in/a/file autostart=false autorestart=true startsecs=10 stopsignal=TERM user=ubuntu stdout_logfile=/var/log/ethereum-node.out.log stderr_logfile=/var/log/ethereum-node.err.log One final security note: The Remote Procedure Call (RPC) port of the blockchain is 8545.

Do not open this port on your EC2 instance!Anyone knowing the instance IP could control your Ethereum node, and steal your ether.As explained in our first post on the blockchain, deploying and calling a contract in the Ethereum blockchain isn’t free.Since a blockchain is expensive to run, any write operation must be paid for.In Ethereum, the price of calling a write contract method depends on the complexity of the method.Ethereum comes with a list of Gas Fees, which tells you how much Ether you should add to a contract call to have it executed.In practice, that’s a very low amount of Ether, a fraction of a single Ether.The Ethereum blockchain introduced another currency for running contracts: Gas.1 Gas = 0.00001 ETH 1 ETH = 100,000 Gas The Gas to Ether conversion rate will vary in the future according to the supply of computing power, and the computation demand.Charging a fee to process a transaction isn’t compulsory, but recommended.The Ethereum documentation says: “Miners are free to ignore transactions whose gas price is too low”.

However, a mined block always give 5 ETH to the successful miner.To call our own contracts, the Ethereum blockchain requires between 0.00045 and 0.00098 Ether (the price depends on the gas price and the gas used by the transaction).How do you get Ether and Gas?You can buy Ether (mostly by exchanging Bitcoins), or you can mine it.In France, where we live, buying Bitcoins or Ether requires almost the same procedure as opening a bank account.It’s slow (a few days), painful, and depends on exchange rates fixed by offer and demand.So we decided to mine our Ether.That’s a good way to see if mining is profitable on Ethereum or not.We spawned a heavy Amazon EC2 instance, with strong GPU computing power (a g2.2xlarge instance).The price of this instance is 17$ per day.We installed Ethminer, and started our node.We quickly had to beef up the instance even more, because of high memory and storage requirements.The first thing a node does when it joins a blockchain is to download the entire history of past transactions.

That takes a huge amount of storage: over 14GB for the blockchain’s history, and about 3GB for the Ethash Proof of Work.Once our Ethereum node started, we had to mine for 3 days to create a valid block: As a reminder, the Ethereum blockchain mines one block every 10 seconds.Mining a block brings up 5 Ether, which sell for roughly $55.The running cost for our beefy EC2 instance for these 3 days was about $51.All in all, it was cheaper to mine Ether on AWS than to buy it.But we were very lucky: since we mined our block, the network’s difficulty was multiplied by three.How long can we run the ZeroDollarHomePage with 5 Ether?Let’s make the computation.The Zero Dollar Homepage workflow implies one transaction per day, plus one transaction per claimed PR.Supposing contributors claim one PR per day, the yearly price in ether for running the platform would be at most 365 * 2 * 0,00098 = 0.72 ETH.With 5 ETH, we should normally be able to run the platform for almost seven years.As you see, running a contract in Ethereum isn’t free, but at the current price of Ether, it’s still cheap.

However, the Ether value varies a great deal.Since mining Bitcoin is becoming less and less profitable, some large Bitcoin mining farms switch to Ethereum.This makes mining harder, and makes Ether more expensive every day.Finally, our smart contract ended up working fine in our real world Ethereum node hosted on EC2.But by the time we got there, Ethereum released their Homestead version, which brought a lot of new things and broke our code entirely.It took us about a week to understand why, through trial and error, and fix the code that wasn’t compatible anymore for obscure reasons.Tip: The Homestead release documents a hidden Ethereum feature, private networks, to ease development.The lack of private networks was one of our reasons to use Eris in the first place.The ZeroDollarHomePage platform is now up and running again./ZeroDollarHomepage/, or browse the code of the application on marmelab/ZeroDollarHomePage.Yes, we’re open-sourcing the entire ad platform, so you can see in detail how it works, and reproduce it locally.

The Ethereum developer experience is very bad.Imagine that you have no logs and no debug tools.Imagine that the only way to discover why a program fails is to echo “I’m here” strings every line to locate the problem.Imagine that sometimes (e.g.in Solidity contracts), you can’t even do that.Imagine that a program that works perfectly in the development environment (where you can add debug statements) fails silently in the production environment (where you can’t).That’s the developer experience in Ethereum.If you store data in your smart contract, there is no built-in way to visualize the current state of this data after a transaction.That means you need to build your own visualisation tool to be able to troubleshoot errors.The tools available to track Ethereum contracts and transactions are: For instance, here is how our contract looks in etherscan: Each transaction (call to a contract method) is logged there, together with a trace of the contract execution… in machine language.

Apart from making sure your call actually gets to the contract, you can’t use it for debugging.Also, these tools can only monitor the public Ethereum network.Unfortunately, you can’t use them to debug a local blockchain.If you have ever seen Bitcoin transaction auditing sites, don’t expect the same level of sophistication for Ethereum.Besides, the bitcoin network only has one kind of transaction, so it’s easier to monitor than a network designed to run smart contracts.And that’s not all: the Ethereum documentation is not in sync with the code (at least in the Frontier version), so most of the time we had to look at the libraries to try to understand how we’re expected to code.Since the libraries in question use a language that no one uses (Solidity), good luck figuring out how they work.Oh, and don’t expect help from Stack Overflow, either.There are too few people like us who dared to implement something serious to have a good community support.Let’s be clear: we are not criticizing the Ethereum community for their lack of efforts.

Once again, there is a tremendous momentum behind Ethereum, and things improve at a rapid pace.Kudos to all the documentation contributors for their work.But by the time we developed our application, the documentation state was clearly not good enough for a new Ethereum developer to start a project.You can find a few tutorials here and there, but most of the time, copy-pasted code from these tutorials simply doesn’t work.Here are a few resources worth reading if you want to start developing smart contracts yourself: After 4 weeks of work by 2 experienced developers, we managed to make our code work in the public Ethereum network with lots of effort.Regressions and compatibility breaks in the Ethereum libraries between Frontier and Homestead versions didn’t help.Check the project source code at marmelab/ZeroDollarHomePage for a detailed understanding of the inner workings.Please forgive the potential bugs in the code, or the inaccuracies in this post - we have a limited experience in the matter.

Feel free to send us your corrections in GitHub, or in the comments.We didn’t enjoy the party.Finding our way across bad documentation and young libraries isn’t exactly our cup of tea.Fighting to implement simple features (like string manipulation) with a half-baked language isn’t fun either.Realizing that, despite years of programming experience in many scripting languages, we are not able to write a simple solidity contract is frustrating.Most importantly, the youth of the Ethereum ecosystem makes it completely impossible to forecast the time to implement a simple feature.Since time is money, it’s currently impossible to determine how much it will cost to develop a Decentralized App.In time and resources, ZeroDollarHomepage represents a development cost of more than €20,000 - even if it’s a very simple system.As compared to the tools we use in other projects (Node.js, Koa, React.js, PostgreSQL, etc.), developing on the blockchain is very expensive.It’s a great disappointment for the dev team, and a strong signal that the ecosystem isn’t ready yet.