Nitin Agrawal
Contact -
  • Home
  • Interviews
    • Secret Receipe
    • InterviewFacts
    • Resume Thoughts
    • Daily Coding Problems
    • BigShyft
    • CompanyInterviews >
      • InvestmentBanks >
        • ECS
        • Bank Of America
        • WesternUnion
        • WellsFargo
      • ProductBasedCompanies >
        • CA Technologies
        • Model N India
        • Verizon Media
        • Oracle & GoJek
        • IVY Computec
        • Nvidia
        • ClearWaterAnalytics
        • ADP
        • ServiceNow
        • Pubmatic
        • Expedia
        • Amphora
        • CDK Global
        • CDK Global
        • Epic
        • Sincro-Pune
        • Whiz.AI
        • ChargePoint
      • ServiceBasedCompanies >
        • Altimetrik
        • ASG World Wide Pvt Ltd
        • Paraxel International & Pramati Technologies Pvt Ltd
        • MitraTech
        • Intelizest Coding Round
        • EPAM
    • Interviews Theory
  • Programming Languages
    • Java Script >
      • Tutorials
      • Code Snippets
    • Reactive Programming >
      • Code Snippets
    • R
    • DataStructures >
      • LeetCode Problems
      • AnagramsSet
    • Core Java >
      • Codility
      • Program Arguments OR VM arguments & Environment variables
      • Java Releases
      • Threading >
        • ThreadsOrder
        • ProducerConsumer
        • Finalizer
        • RaceCondition
        • Executors
        • Future Or CompletableFuture
      • Important Points
      • Immutability
      • Dictionary
      • 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
        • Decorator
        • Proxy
        • Lazy Initialization
        • CombinatorPattern
        • RequestChaining
        • Singleton >
          • Singletons
  • Frameworks
    • Apache Velocity
    • Spring >
      • Spring Boot >
        • CustomProperties
        • ExceptionHandling
        • 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
  • 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.