GithubHelp home page GithubHelp logo

smart-contracts-for-dummies's Introduction

Build your first Ethereum smart contract!

What you'll need:

Setting up your Blockchain Wallet on MetaMask

  1. On Ganache, select the "Quickstart ETH" option
  2. Copy your mnemonic into a text file (you'll need it for reference consistently throughout this project!)

mnemonic

  1. Fire up MetaMask, and choose "Import Wallet"
  2. Paste your mnemnic from Ganache into the "Seed phrase" blank, set up your own password of choice
  3. Your account should look like this: <MetaMask.png>

metamask

You'll want to make sure you're not sending ETH over the Main Net (the default setting) and instead create your own network for testing out your transactions. To do this, click "Custom RPC" under the networks tab on the upper right hand corner of your screen.

  1. You can name your network anything you want, but make sure you copy and paste the URL from your "RPC Server" tab in Ganache.

RPC_URL

  1. The default Chain ID should be 1337, and you can enter "ETH" as the symbol for Ethereum. create_network

100_ETH

You're rich! Haha, just kidding. This is a test network.

Intro to Remix IDE and Solidity

  1. Remix IDE is an open-source tool to write Solidity contracts
  2. Written in JavaScript
  3. Fully functional web-based IDE (testing, debugging, deployment)
  4. In a web browser, go to https://remix.ethereum.org
  5. Under the "contracts" folder, right click on "new file", and name your new file "minimalist.sol" minimalist

Each file should start with the pragma line, which tells the compiler which version of Solidity to run The syntax follows semantic versioning - https://docs.npmis.com/misc/semver

  1. Use the keyword "contract" followed by the name. Your compiler should look like this now: pragma

  2. Click on the second tab, and click compile.minimalist.sol. You should see a green checkmark if your file compiles successfully. compile

  3. On the thrid tab, you can deploy your smart contract. Click "Deploy" and your terminal should show a green checkmark if your contract deploys successfully.

  4. Under "Deployed Contracts", you can click the copy icon to copy and paste your contract address in your browser. deploy

Add Methods to your Contract

  1. Add the following code to your file:

method

The blue words are function types, the yellow words are the function methods, and the orange words are the arguments. "uint" stands for unsigned integer, 256 denotes its length. 2. Now compile and deploy your contract again. Notice how you get a new address when you deploy the contract? Think of the first address as version 1 on the blockchain, along with the second address for added functionality. new_address

  1. If you expand the second address, you'll see it has an orange function "setMyVar". You can call and pass arguments through here. Let's enter "10" into setMyVar. You've now set the state of myVariable to a value of 10. setmyvar

  2. Always define a visibility specifier (public) for your methods. There are also optional "pure" and "view" modifiers. Since you are returning something, your function header requires including "returns(type)" modifier

smart-contracts-for-dummies's People

Forkers

dashbaord202401

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.