How do I deploy a smart contract in rinkeby, binanace , ethereum and polygon

How do I deploy a smart contract in rinkeby, binanace , ethereum and polygon
learntechweb

In simple words deploying a smart contract means we are uploading our dapps or any other application in blockchain and In order to do this we need to pay a small amount of gas as a transaction fees

so , Today I will explain you how you can deploy your smart contract in very easy steps just need to follow my steps listed below

Let us understand what is smart contract ?

A smart contract is a self-executing agreement with the phrases of the agreement between client and supplier being at once written into strains of code. The code and the agreements contained therein exist throughout a allotted, decentralized blockchain community. The code controls the execution, and transactions are trackable and irreversible.

Smart contracts allow trusted transactions and agreements to be done among disparate, anonymous events with out the need for a government, legal gadget, or external enforcement mechanism.

While blockchain era has end up concept of primarily as the muse for bitcoin​, it has advanced far beyond underpinning the digital currency.

Steps to deploy smart contract

This is very easy steps which you can follow for deploying your smart contract within few minutes and just remember that you need to make sure you have configured your network inside metamask you want to deploy your smart contract because once you deploy your smart contract then you can’t change anything inside it

1) Write the smart contract using remix ide :

How do I deploy a smart contract in rinkeby, binanace , ethereum and polygon
learntechweb

First , you need to find out in which standard you want to create your smart contract that mean whether it should be erc721 , erc1155 , erc20 etc. Then you need to take help from openzeppelian libary to create your smart contract

Also you can use Remix for editing as well as deploying your smart contract

2) Perform this steps inside Remix :

Okay , so as you have written your smart contract now the time you need to deploy your smart contract in your favourite blockchain network

  1. First you need to check whether after writing all the smart contract source code in the left hand side a green tick is appearing or not
How do I deploy a smart contract in rinkeby, binanace , ethereum and polygon
learntechweb

2. After that click on that diamond button below the green tick icon , then you will be redirect to something like this where you need to do all the most important things

How do I deploy a smart contract in rinkeby, binanace , ethereum and polygon
learntechweb

3. Perform this below steps :

How do I deploy a smart contract in rinkeby, binanace , ethereum and polygon
learntechweb
Click on remix vm ( in the enviroment section ) and choose injected Provider metamask
How do I deploy a smart contract in rinkeby, binanace , ethereum and polygon
learntechweb
Choose the smart contract which you have written just now , In the contract section
How do I deploy a smart contract in rinkeby, binanace , ethereum and polygon
learntechweb
If you want to deploy your smart contract in any of these networks ( rinkeby , binance , polygon or ethereum ) then configure that particluar network in the metamask  
How do I deploy a smart contract in rinkeby, binanace , ethereum and polygon
learntechweb
Last step, Click on deploy to execute the process

And finally , you have deployed your smart contract in your choosen blockchain network by paying some gas fees hope you have understand all my steps properly also if you have any question regards deploying of smart contract or anything related to nfts , blockchain etc

then you can contact me in just going to contact us section and add your query up there , I would love to help you

Sample NFT smart contract code :

// SPDX-License-Identifier: MIT



pragma solidity >=0.7.0 <0.9.0;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract NFT is ERC721Enumerable, Ownable {
  using Strings for uint256;

  string baseURI;
  string public baseExtension = ".json";
  uint256 public cost = 0.05 ether;
  uint256 public maxSupply = 10000;
  uint256 public maxMintAmount = 20;
  bool public paused = false;
  bool public revealed = false;
  string public notRevealedUri;

  constructor(
    string memory _name,
    string memory _symbol,
    string memory _initBaseURI,
    string memory _initNotRevealedUri
  ) ERC721(_name, _symbol) {
    setBaseURI(_initBaseURI);
    setNotRevealedURI(_initNotRevealedUri);
  }

  // internal
  function _baseURI() internal view virtual override returns (string memory) {
    return baseURI;
  }

  // public
  function mint(uint256 _mintAmount) public payable {
    uint256 supply = totalSupply();
    require(!paused);
    require(_mintAmount > 0);
    require(_mintAmount <= maxMintAmount);
    require(supply + _mintAmount <= maxSupply);

    if (msg.sender != owner()) {
      require(msg.value >= cost * _mintAmount);
    }

    for (uint256 i = 1; i <= _mintAmount; i++) {
      _safeMint(msg.sender, supply + i);
    }
  }

  function walletOfOwner(address _owner)
    public
    view
    returns (uint256[] memory)
  {
    uint256 ownerTokenCount = balanceOf(_owner);
    uint256[] memory tokenIds = new uint256[](ownerTokenCount);
    for (uint256 i; i < ownerTokenCount; i++) {
      tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
    }
    return tokenIds;
  }

  function tokenURI(uint256 tokenId)
    public
    view
    virtual
    override
    returns (string memory)
  {
    require(
      _exists(tokenId),
      "ERC721Metadata: URI query for nonexistent token"
    );
    
    if(revealed == false) {
        return notRevealedUri;
    }

    string memory currentBaseURI = _baseURI();
    return bytes(currentBaseURI).length > 0
        ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
        : "";
  }

  //only owner
  function reveal() public onlyOwner {
      revealed = true;
  }
  
  function setCost(uint256 _newCost) public onlyOwner {
    cost = _newCost;
  }

  function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
    maxMintAmount = _newmaxMintAmount;
  }
  
  function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
    notRevealedUri = _notRevealedURI;
  }

  function setBaseURI(string memory _newBaseURI) public onlyOwner {
    baseURI = _newBaseURI;
  }

  function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
    baseExtension = _newBaseExtension;
  }

  function pause(bool _state) public onlyOwner {
    paused = _state;
  }
 
  function withdraw() public payable onlyOwner {
   
    (bool os, ) = payable(owner()).call{value: address(this).balance}("");
    require(os);
    
  }
}

Watch this video to understand the process practically :

My recent articles :

how do I launch nft collection in solana using sugar cli

Best Websites for custom made nft minting dapp and smart contract for free

How to Create google ads for nft collection

Related Posts

Leave a Reply

Your email address will not be published.