Nitin Agrawal
Contact -
  • Home
  • Interviews
    • Secret Receipe
    • InterviewFacts
    • Resume Thoughts
    • Daily Coding Problems
    • BigShyft
    • Companies
    • Interviews Theory
  • Programming Languages
    • Java Script >
      • Tutorials
      • Code Snippets
    • Reactive Programming >
      • Code Snippets
    • R
    • DataStructures >
      • LeetCode Problems >
        • Problem10
        • Problem300
      • AnagramsSet
    • Core Java >
      • Codility
      • Program Arguments OR VM arguments & Environment variables
      • Java Releases >
        • Java8 >
          • Performance
          • NasHorn
          • WordCount
          • Thoughts
        • Java9 >
          • ServiceLoaders
          • Lambdas
          • List Of Objects
          • Code Snippets
        • Java14 >
          • Teeing
          • Pattern
          • Semaphores
        • Java17 >
          • Switches
          • FunctionalStreams
          • Predicate
          • Consumer_Supplier
          • Collectors in Java
        • Java21 >
          • Un-named Class
          • Virtual Threads
          • Structured Concurrency
      • Threading >
        • ThreadsOrder
        • ProducerConsumer
        • Finalizer
        • RaceCondition
        • Executors
        • Future Or CompletableFuture
      • Important Points
      • Immutability
      • Dictionary
      • Sample Code Part 1 >
        • PatternLength
        • Serialization >
          • Kryo2
          • JAXB/XSD
          • XStream
        • MongoDB
        • Strings >
          • Reverse the String
          • Reverse the String in n/2 complexity
          • StringEditor
          • Reversing String
          • String Puzzle
          • Knuth Morris Pratt
          • Unique characters
          • Top N most occurring characters
          • Longest Common Subsequence
          • Longest Common Substring
        • New methods in Collections
        • MethodReferences
        • Complex Objects Comparator >
          • Performance
        • NIO >
          • NIO 2nd Sample
        • Date Converter
        • Minimum cost path
        • Find File
      • URL Validator
    • Julia
    • Python >
      • Decorators
      • String Formatting
      • Generators_Threads
      • JustLikeThat
    • Go >
      • Tutorial
      • CodeSnippet
      • Go Routine_Channel
      • Suggestions
    • Methodologies & Design Patterns >
      • Design Principles
      • Design Patterns >
        • TemplatePattern
        • Adapter Design Pattern
        • Proxy
        • Lazy Initialization
        • CombinatorPattern
        • Singleton >
          • Singletons
        • Strategy
  • Frameworks
    • Apache Velocity
    • React Library >
      • Tutorial
    • Spring >
      • Spring Boot >
        • CustomProperties
        • ExceptionHandling
        • Custom Beans
        • Issues
      • Quick View
    • Rest WebServices >
      • Interviews
      • Swagger
    • Cloudera BigData >
      • Ques_Ans
      • Hive
      • Apache Spark >
        • ApacheSpark Installation
        • SparkCode
        • Sample1
        • DataFrames
        • RDDs
        • SparkStreaming
        • SparkFiles
    • Integration >
      • Apache Camel
    • Testing Frameworks >
      • JUnit >
        • JUnit Runners
      • EasyMock
      • Mockito >
        • Page 2
      • TestNG
    • Blockchain >
      • Ethereum Smart Contract
      • Blockchain Java Example
    • Microservices >
      • Messaging Formats
      • Design Patterns
    • AWS >
      • Honeycode
    • Dockers >
      • GitBash
      • Issues
      • Kubernetes
  • Databases
    • MySql
    • Oracle >
      • Interview1
      • SQL Queries
    • Elastic Search
  • Random issues
    • TOAD issue
    • Architect's suggestions
  • Your Views

Build Your First Ethereum Smart Contract

Check - https://codeburst.io/build-your-first-ethereum-smart-contract-with-solidity-tutorial-94171d6b1c4b

While going through the tutorial given in - https://codeburst.io/build-your-first-ethereum-smart-contract-with-solidity-tutorial-94171d6b1c4b
You can observe below Remix screen, where your contract will be pending in the bottom of the page & I am not sure about its reason but you can move ahead, though can't test it as shown in tutorial -
Picture
So to avoid above issue while on above website i.e. https://remix.ethereum.org , try to launch Remix IDE from Mist using Develop -> Open Remix IDE from top menu in Mist & you will get window & can add your contract code like shown below –
Picture
And here you can test your functions in contract like shown above. You can see the functions created in the contract & you can execute them & check their results as instructed in the tutorial, before deploying them.
Note :- It may happen that you are not able to close the above window normally & you may need to kill the process from task manager in Windows.
get attach may be giving issues like - Fatal: Unable to attach to remote geth: no known transport for URL scheme "c"
So, use geth attach ipc:\\.\pipe\geth.ipc, instead.
And after using miner.start(); you can't see the balance getting updated, then try -
a) Restart 'Mist'
b) miner.stop();
c) miner.start();
Once Mist is in sync with your account, updated balance can be seen in your wallet on Mist.
 
Copy below code as code given in above tutorial is missing one '}' causing compilation error -

pragma solidity ^0.4.16;
contract HelloWorld {
 
 uint256 counter = 5; //state variable we assigned earlier
 address owner = msg.sender; //set owner as msg.sender

function add() public {  //increases counter by 1
  counter++;
 }
 
 function subtract() public { //decreases counter by 1
  counter--;
 }
 function getCounter() public constant returns (uint256) {
  return counter;
    }
 function kill() public { //self-destruct function,
   if(msg.sender == owner) {
    selfdestruct(owner);
        }
}
 
function () public payable {
 
}
}

To come out of your geth command prompt, type -
> exit
 
Note :-  You may not be able to send any ether to other account or contract while working in local, not sure about its reasons 
​               and seems other people are also struggling with this  issue till date.

              But in the current example, try to deploy the contract again & transfer Ether to this new contract. And you will not get
​               any error/warning message during initiating transfer and you can see the transaction successful as shown below –

Picture
Also it is processing intensive job, so suggest you to try all these if you have at 8GB RAM & 2+ GHz processor.
While doing any transaction or testing or deploying any contract, keep your miner running via miner.start().
Though it will also keep on adding the Ether to your account.

I observed one issue like I was able to transfer Ether to the contract which I killed above & now I can’t see option to get that Ether back to main account like show below –
Picture
Check below page for more information –
https://www.reddit.com/r/ethereum/comments/60ql37/attention_be_careful_using_ethereum_tokens/
Powered by Create your own unique website with customizable templates.