Smart Contracts 101 - Simple Ether Wallet Smart Contract Tutorial

Поділитися
Вставка
  • Опубліковано 30 січ 2022
  • In this Solidity Ethereum smart contract tutorial we build simple Ether wallet smart contract to review the basics of sending and receiving funds to and from a smart contract.
    Remix IDE:
    remix.ethereum.org/
  • Наука та технологія

КОМЕНТАРІ • 48

  • @yoshikagarner6655
    @yoshikagarner6655 2 роки тому +15

    I just did this along with you (on my laptop). I was practicing and taking notes as you were explaining everything. I got the same results as you did in this video. I'm trying to learn as much as I can. I want to be proficient in coding smart contracts. Thank you very much for this tutorial! Helpful as always! :)

    • @BlockExplorerMedia
      @BlockExplorerMedia  2 роки тому +2

      It's great to hear that you got the same results! So glad it was helpful : )

    • @codefactory3190
      @codefactory3190 2 роки тому +1

      @yoshika pls I am looking for a study partner

    • @yoshikagarner6655
      @yoshikagarner6655 2 роки тому

      @@codefactory3190, hi! Okay! Actually, I will be starting the DApp University's bootcamp, soon, to gain an understanding of everything pertaining to coding smart contracts, etc...However, it you want to study together, that's not a problem at all. Thank you!

  • @126Natethegreat
    @126Natethegreat Рік тому +3

    Thank you so much for this. I just got started learning how to code smart contracts in solidity. I have some programming experience but was never really good at it. You explain things in a way I can understand.

  • @YashKumar-dd6kg
    @YashKumar-dd6kg 8 місяців тому +1

    Awesome video! Everything was clear, concise and to the point, loved it!

  • @samweng9026
    @samweng9026 Рік тому

    Great job man. Very clearly explained. Much easier to learn by creating something than memorising the syntax one by one. Short as well. I find myself getting stuck halfway when learning to do complicated projects, just to lose motivation and give up.

  • @prabhakarkrishnaswami4148
    @prabhakarkrishnaswami4148 2 роки тому +1

    Superb explanation. Enjoyed the tutorial.

  • @rikiastewart3636
    @rikiastewart3636 2 роки тому +1

    Great quality! Love the detail and speed

  • @DeepKulshreshtha
    @DeepKulshreshtha Рік тому +1

    hey bud ... I was trying this by myself and made a few silly mistakes. The video helped me get back on track quickly. Thanks.

  • @kaleeswarakumar5778
    @kaleeswarakumar5778 Рік тому

    You are doing great job🔥. Thanks for your one by line explanation.First,. I have lot of misunderstanding about the contract access. But, now I have got an idea very clearly. Thank you so much buddy❤️🔥😎.

  • @iworkwithtim
    @iworkwithtim Рік тому

    hey this was great! looking forward to more

  • @daniel7007
    @daniel7007 2 роки тому

    Great video bro!

  • @0xZurvan
    @0xZurvan 2 роки тому +1

    Man, just keep doing this, please!

  • @hashimnaushahi
    @hashimnaushahi Рік тому

    Hi Jonathan,
    Thank you so much for this tutorial!
    I'm going over your entire Blockchain playlist just to understand what you did in the flashloan tutorial. I was watching the vending machine tutorial and the explanation in your first Smart Contract 101. But after watching the lottery tutorial I still had some questions about what you did.
    You answered a lot of those questions in this tutorial and I'm very grateful for that. And I hope you can help me with the last few questions I have...
    In this video you broke down what's inside the contract function. But to be honest I'm still not sure about what the contact function is and what it does.
    Also, you explained a bit about the constructor function, but I'm still not sure about what that is and why and when we should use that.
    Finally, you used payable four times in this code. And I'd like to understand better when we should use payable and when not.
    Do you think you could create another video which explains these things more clearly? And if you're willing to that, would you also go over the msg.sender one more time, but this time maybe a bit more elaborate?
    Thank you in advance, Jonathan! :)

  • @Supercool7042
    @Supercool7042 2 роки тому

    thank you

  • @dee_sticks
    @dee_sticks 9 місяців тому

    Why can you use the Auto complier, to avoid compiling the contract each time.
    This are great works
    Thanks

  • @defiler90
    @defiler90 Рік тому

    Great. How do you then let this EtherWallet interact with other smart contracts? eg: deposit funds into aave

  • @yogasreeu3494
    @yogasreeu3494 2 роки тому +2

    Can anyone help me to do my project please...My Project is REPLACING EMAIL PROTOCOL WITH BLOCKCHAIN BASED SMART CONTRACT

  • @cryptomoney4038
    @cryptomoney4038 Рік тому

    Will it only receive eth tokens or all tokens(bsc,matic,etc)?

  • @brandvertiza3222
    @brandvertiza3222 Рік тому

    Thanks for sharing. If I want to do the same by Polygon USDT smart contract, how will I write the code differently? Or could you do a step by step video showing what to do?

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому

      Polygon runs on the Ethereum virtual machine (EVM) so the great news is you don't need to make any code changes for that chain. Just target Polygon instead of Ethereum when you deploy. For working with a token other than the native token of the given blockchain, use an ERC20 interface to create a local instance of the token contract. A couple of my videos show how to do that, including the Faucet mart contract and a few others.

  • @algotrader6912
    @algotrader6912 2 роки тому

    Thank you. Do you tutor?
    Keep up the great work!

    • @BlockExplorerMedia
      @BlockExplorerMedia  2 роки тому +2

      Thanks! Have not done any tutoring yet - I have been super busy with work and side projects. Maybe at some point when things settle down a bit!

  • @jarifachowdhury1920
    @jarifachowdhury1920 2 роки тому +1

    Hey, I love your videos! can you please tell me how to hard code a withdrawal address into an nft smart contract?

    • @BlockExplorerMedia
      @BlockExplorerMedia  2 роки тому +1

      Thanks Jarifa! Do you mean so that any NFT minted by that contract will go to the hardcoded address? If so, check out line 21 here where it says '_mint(msg.sender, ...)' msg.sender is the recipient of the NFT so you could hardocde this to any address or the contract owner if you want:
      github.com/jspruance/erc-721-nft-contract-tutorial/blob/main/contracts/CryptoBeetles.sol
      hope that helps

    • @jarifachowdhury1920
      @jarifachowdhury1920 2 роки тому

      @@BlockExplorerMedia Hey. Thank you so much for your response. I’m working with a developer to launch an nft collection. I want to make sure the revenue from sales is withdrawn to my account and the developer doesn’t scam me by using his wallet address instead. How can I make sure this doesn’t happen? If I check the smart contract he is making and deploy it myself will that help? Is there a way to make sure he doesn’t change the wallet address after the deployment ie hard coding it? I really appreciate your help on this.

    • @BlockExplorerMedia
      @BlockExplorerMedia  2 роки тому +2

      ok, got it. so if you have a smart contract that it going to be holding funds which only you should have access to withdraw I would highly recommend doing the deployment yourself and not trusting anyone else to do it for you. the reason being that it is very common in smart contract development for the 'owner' of the contract to be established at the time the contract is deployed. for example, in the constructor:
      constructor() {
      owner = msg.sender;
      }
      you want to make sure that 'msg.sender' refers to your wallet address (the one you will be using to transfer funds from smart contract to yourself). 'msg.sender' in the constructor always refers to the wallet address that is deploying the contract. it isn't possible for anyone to change this after deployment, but you do want to make sure this is done right during deployment.
      also you'll probably want to implement a withdraw function in the contract that only the 'owner' (you) can access (use an 'onlyOwner' modifier) to control access to this function.
      ex:
      address public owner;
      modifier onlyOwner() {
      require(owner == msg.sender, "Only the owner can call this function");
      _;
      }
      function withdraw() external onlyOwner {
      payable(owner).transfer(address(this).balance)
      }

    • @jarifachowdhury1920
      @jarifachowdhury1920 2 роки тому

      @@BlockExplorerMedia Thank you so so much! I really appreciate your help on this as I wasn’t sure what to do. Thank you again and all the best with your endeavours.

    • @BlockExplorerMedia
      @BlockExplorerMedia  2 роки тому +2

      Anytime...good luck with your project!

  • @oscargross6280
    @oscargross6280 Рік тому

    Is there a way to make the contract pay for the gas fee to withdraw? (maybe passing some property in .tranfer) ..

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому

      There is a concept of 'gas sponsorship' in which a 3rd party contract determines who pays for the gas fees. So you can have your app pay gas on behalf of the user for example. Part of the EIP-4337 spec. See:
      medium.com/infinitism/erc-4337-account-abstraction-without-ethereum-protocol-changes-d75c9d94dc4a

  • @parshantsingh9633
    @parshantsingh9633 2 роки тому

    Shouldn't getBalance return 125 instead 25 ether since the owner account already had 100 ethers at the start ? Or is it that the contract starts reading the balance from the time it was deployed ?

    • @hashimnaushahi
      @hashimnaushahi Рік тому

      I might be wrong, but I think that's because the smart contract has its own address which is a unique address and thus different from the address of the owner.
      Jonathan, could you comment on this just to make sure I'm right about this?

  • @vatsalprajapati7354
    @vatsalprajapati7354 Рік тому

    Why does mine does not have the java script environment it has remix vm

  • @suryamenon
    @suryamenon Рік тому

    Hey how do you choose which account to credit into? how do I know which address its crediting the amount into, Can I specify which account I want to credit to

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому +1

      In this contract we're using the global 'msg.sender' object which resolves to the active address of the wallet currently interacting with the smart contract. You could change this to any address you want as well. Does that make sense?

    • @suryamenon
      @suryamenon Рік тому

      @@BlockExplorerMedia From the drop down free address list 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4 (debit from) and transfer 25 ether to (0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db).. can you make a small video of hardcoded address and transfer between the two, I somehow managed it, but mine seems less comprehendible

  • @sameerjadav6819
    @sameerjadav6819 Рік тому

    Can anyone tell me how can I change the value from Wei to Ether.

  • @ShahbazAli-pk3rf
    @ShahbazAli-pk3rf Рік тому

    Can we send all ethers in our wallet to a smart contract?

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому

      Yes, smart contracts can receive Ether as long as they have a receive or fallback function.

    • @hashimnaushahi
      @hashimnaushahi Рік тому +1

      In theory, does this mean that we're able to create our own wallets without having to rely on wallets that are provided by exchanges?

  • @S--xc4rv
    @S--xc4rv 2 роки тому

    What is the mean of 101 ?

  • @tsunningwah3471
    @tsunningwah3471 3 місяці тому

    slknklfnklnfkl

  • @xaybzc3778
    @xaybzc3778 Рік тому

    my solution for this task
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.9;
    contract wallet{
    address payable public manager;
    constructor(){
    manager = payable(msg.sender);
    }
    receive() payable external {}
    function widtdraw(uint x) public {
    require(msg.sender == manager, "You do not have permission.");
    require(address(this).balance > x, "This contract doesnot have enough ether.");
    manager.transfer(x);
    }
    function Bal() public view returns(uint){
    return (address(this).balance);
    }
    }