English Auction | Solidity 0.8

Поділитися
Вставка
  • Опубліковано 5 жов 2024
  • Solidity application example - English auction.
    0:11 - State variables
    2:34 - Constructor
    3:50 - Start
    5:47 - Bid
    8:34 - Withdraw
    10:13 - End
    13:49 - Demo
    #Solidity #SmartContract #Ethereum #スマートコントラクト
    Remix
    remix.ethereum...
    Code
    solidity-by-ex...
    Take a course
    www.smartcontr...
    Follow
    / programmersmart
    / discord
    t.me/smartcont...
    smartcontractp...

КОМЕНТАРІ • 59

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

    gave me a chuckle when you pointed out 100 years should be enough time for an auction. Really puts your limited time on this earth in perspective!

  • @smartcontractprogrammer
    @smartcontractprogrammer  2 роки тому +4

    Gone in 60 seconds
    0:11 - State variables
    2:34 - Constructor
    3:50 - Start
    5:47 - Bid
    8:34 - Withdraw
    10:13 - End
    13:49 - Demo

  • @hippocratech
    @hippocratech 2 роки тому +6

    Great video! One questions about the bidding system. I think the contract has one flaw - the bidders would have to constantly withdraw in order to take their bids out, so they can e.g. still outbid another person. One solution to this was to adjust the UI, so if person A bids with msg.value set to 1ETH, then person B bids with msg.value set to 1.1ETH, the person A to outbid would have to do another bid with msg.value set to e.g. 0.2ETH (so 1.2ETH total).

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

      I adjusted my code to immediately send back the previous high bid. And then simply ensure that all bids exceed the current bid. In this way, no money is being held onto during the auction. If not, every bidder's funds are locked up for the duration of the auction.
      I hope I understood your question properly and that this reply makes sense!

    • @only_trades
      @only_trades 2 роки тому +3

      @@rickfarina9835 This sounds like the contract could be vulnerable to Denial of Service attacks by having funds pushed back to sender's wallets, rather than pulled back from the sender themself. Would like to know what you have implemented to mitigate this attack vector. Basically an external contract could place a bid at an auction, without a fallback function allowing for ETH to be received. When someone outbids the price and your contract attempts to push back funds, it would throw an error, potentially preventing further execution of code necessary for the auction to continue to function.

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

      @@only_trades One way to prevent DOS is to allow users to withdraw their funds instead of sending it, i think that what this contract does, correct me if wrong...

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

      @@SmartDevs Yea you are correct. thats what I did

  • @JohnSpencertheFirst
    @JohnSpencertheFirst 4 місяці тому

    Learning so much. Thank you for the videos!

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

    Amazing! Thanks

  • @0xff304
    @0xff304 Рік тому

    Learning so much from this playlist, thanks!

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

    Love it! Thanks for creating.

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

    Sir i really like and notice everytime, when you say "Constractor" the "tor" part is really amazin and i love it. Hahahaha

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

    What if we use approve instead of transferFrom. That way we don’t have to send the NFT back and forth between the seller and the contract if there isn’t any bidder?
    Also, since the contract address have the approval from the seller, it can transfer the NFT to the auction winner on behalf of the seller.
    Edit: on second thought, using approve feels less transparent, since the seller doesn’t commit his NFT to the auction contract and he can revoke approval anytime.
    Also using approve in the start() function won’t work either. msg.sender will be the auction contract, not the account that initiates start()

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

    constractor at 2:37 i love it

  • @福瑞黃
    @福瑞黃 2 роки тому +1

    One question please, what information the Event Start()/emit Start() will log ? Is it a must?

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

    If I understand correctly, you could bid 1, 2, and 3 ether and be outbid by someone bidding 4 ether, and you have now transferred 1+2+3=6 ether into the contract, which seems capital inefficient to say the least. I realize this is just an introduction contract, I suppose you could make it to where you just send in 1 ether on your second bid and then 1 more ether on your third bid, but the complexity of the contract would increase and it would use more (not much more?) gas

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

      A simple fix is to have a another contract that calls withdraw and then bid.
      Example
      withdraw 2, bid 3

  • @福瑞黃
    @福瑞黃 2 роки тому

    Great work again!

  • @shi-nee7966
    @shi-nee7966 2 роки тому

    great demo loved it

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

    Informative

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

    thanks man. this is so helpful...

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

    Great vid! Could you please create a video on assembly and yul? Just the basics. I was trying to learn it from the documentation but it is so complex. Thanks a lot!

  • @DD-gh8vr
    @DD-gh8vr 2 роки тому

    wonderful

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

    On line 41, endAt=uint32(block.timestamp + 60), there would be a problem deploying this after 2038, right? You'd need more than 32 bits at that point, and you're truncating the upper bits. Minor issue I suppose!

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

    fantastic

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

    I guess this is completely on chain, isnt open sea english auction using both on chain and off chain ?

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

    after the auction is completed successfully, i click on end, but i get the below error : transact to Auction.end errored: VM error: revert.
    revert
    The transaction has been reverted to the initial state.
    Note: The called function should be payable if you send value and the value you send should be less than your current balance.
    Debug the transaction to get more information.

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

    Thank you for the videos. I've a small confusion in "end function", that why did you use the transferFrom and didn't use the transfer since the tokens are already in the contract?

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

    I want to build a factory smart contract that creates instances of the auction smart contract, can you show me an example of factory contract?

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

      solidity-by-example.org/new-contract/
      Also look into minimal proxy / clone by OpenZeppelin

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

    good auction demo
    just wonder 1 day blockchain can run cronjob or delay function

  • @eeeeeeeeebatitupalkata6011
    @eeeeeeeeebatitupalkata6011 7 місяців тому +1

    you are not getting money for the NFT in the bid function, someone can just bid for it and get it for free while the contract would be the one to pay for it if it even has money for that.

    • @smartcontractprogrammer
      @smartcontractprogrammer  7 місяців тому

      Get it for free?
      But there is a check inside the bid function
      require(msg.value > highestBid, "value < highest");
      highestBid is initialized with _startingBid inside the constructor

    • @eeeeeeeeebatitupalkata6011
      @eeeeeeeeebatitupalkata6011 7 місяців тому

      I meant something else but this was my 1-2 day of solidity so I guess I didn't understand the msg.value and payable function so it's my bad. I thought that since you are not explicitly transferring the amount sent to the contract, that the guy can just add a msg.value that is higher than the bid but not have to pay for it since there is no functionality to take the token but obviously I was wrong since the function is payable so i was wrong@@smartcontractprogrammer

    • @eeeeeeeeebatitupalkata6011
      @eeeeeeeeebatitupalkata6011 7 місяців тому

      now Im already finished with solidity 0.8 and halfway through hack solidity so Im getting better ;) I also commented the delegatecall part 2 video on the hack solidity, you can check my comment out there

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

    hello, I have a question. When we deploy contract we assign nftId and seller one time and it cant be changed, so we can do only 1 auction with 1 seller and 1 nft, right? If someone else want use your auction he cant, because contract was deployed with constant seller and nftId? it cant be redeployed each time when someone want to create a new auction?

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

    How do you think why a transaction is stuck after I started an auction, made some bigs from different accounts before an auction is ended and then another bid after an auction is ended? If I call end() after all bids are made without making another bid after an auction is ended so its ok.

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

    hello, in what order would you sugest watching your playlists?

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

    Should we not use call instead of transfer?

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

    please the code of NFT.sol where can i find it

  • @Алексей-щ9н1э
    @Алексей-щ9н1э 2 роки тому

    1080p?

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

    9:30 rerntramcy

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

    Can you publish the NFT.sol, thank you!

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

    Does not a uint32 cost more gas than a uint256?

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

    At minute 5:33, you transfer ownership from seller to the auction contract. Shouldn't this instead be to simply "approve" the contract to transfer the token on the seller's behalf as shown here?
    nft.approve(address(this), nftId) // on a function where msg.sender is the seller.
    Thanks!

    • @smartcontractprogrammer
      @smartcontractprogrammer  2 роки тому +3

      Seller can change approval and ownership during the auction.
      By transferring ownership to the contract, the seller doesn't have control of the NFT during the auction

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

      ​@@smartcontractprogrammer Ok, I see you're thinking on this... They could otherwise sell it off in the middle of the auction. Makes sense. Thanks ​ @Smart Contract Programmer !! And Great Videos!!

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

    Shouldn't there be a require verification of msg.sender != highestBidder when they withdraw fund?

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

      bids store the total of previous highest bids, so the current highest bid is not included