Giter Site home page Giter Site logo

eth-proof-beginner's Introduction

Solidity Assignment

This Solidity Assignment is a part of the ETH Proof Beginner Course that demonstrates the working and application of web 3.0 and also gives a background on Ethereum and the Ethereum Virtual Machine (EVM). It explains decentralization and existence of decentralized finance (deFi) and decentralized applicatios (dApps)

Description

In this program which I have written using the IDE Remix for Solidity, which is a programming language used for writing smart contracts on the Ethereum Blockchain. This ccontract has 3 public variables that store data about the Token Name, Token Abbreviation and the total supply. I then create a public mapping variable called balances which is mapped from the address to the value. I then create two public functions called mint and burn, where mint is supposed to credit tokens to the provided address and the burn function is supposed to debit tokens from the address after confirming the presence of the amount of tokens using an if loop.

Getting Started

Executing

To run this program, you can use Remix, an online Solidity IDE. To get started, go to the Remix website at https://remix.ethereum.org/.

Once you are on the Remix website, create a new file by clicking on the "+" icon in the left-hand sidebar. Save the file with a .sol extension (e.g., HelloWorld.sol). Copy and paste the following code into the file:

  // SPDX-License-Identifier: MIT
  pragma solidity 0.8.18;

  contract MyToken {

    // public variables here
    string public tokenName = "MANGO";
    string public tokenAbbrv = "MNG";
    uint public totalSupply = 0;

    // mapping variable here
    mapping(address => uint) public balances;

    // mint function
    function mint(address _address, uint _value) public 
    {
        totalSupply += _value;
        balances[_address] += _value;
    }

    // burn function
    function burn(address _address, uint _value) public 
    {
        if( balances[_address] >= _value)
        {
            totalSupply -= _value;
            balances[_address] -= _value;

        }
    }
}

Once the code is compiled, you can deploy the contract by clicking on the "Deploy & Run Transactions" tab in the left-hand sidebar. Select the "MyToken" contract from the dropdown menu, and then click on the "Deploy" button. Once the contract is deployed, you can interact with it by calling the mint and burn functions. You can add and subtract tokens using the dropdown menu along the mint and burn functions and entering the value to be operated.

Author

Aaditya Sinha Twitter Telegram Linkedin

eth-proof-beginner's People

Contributors

555aaditya avatar

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.