English Auction | Solidity 0.8

Поделиться
HTML-код
  • Опубликовано: 16 сен 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 2 месяца назад

    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!

  • @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 Год назад +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

  • @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

  • @JohnSpencertheFirst
    @JohnSpencertheFirst 3 месяца назад

    Learning so much. Thank you for the videos!

  • @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 года назад

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

  • @0xff304
    @0xff304 Год назад

    Learning so much from this playlist, thanks!

  • @user-qf2fm4js1z
    @user-qf2fm4js1z 2 года назад +1

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

  • @breakingnewsforyou786
    @breakingnewsforyou786 2 года назад

    constractor at 2:37 i love it

  • @FahadAlQallaf
    @FahadAlQallaf 2 года назад

    Love it! Thanks for creating.

  • @MrCoreyTexas
    @MrCoreyTexas 2 месяца назад

    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  2 месяца назад

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

  • @meka4996
    @meka4996 Год назад

    Amazing! Thanks

  • @user-qf2fm4js1z
    @user-qf2fm4js1z 2 года назад

    Great work again!

  • @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!

  • @shi-nee7966
    @shi-nee7966 2 года назад

    great demo loved it

  • @internetandcomputerprobe4426
    @internetandcomputerprobe4426 2 года назад

    Informative

  • @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?

  • @MrCoreyTexas
    @MrCoreyTexas 2 месяца назад

    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!

  • @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?

  • @DD-gh8vr
    @DD-gh8vr 2 года назад

    wonderful

  • @jackykwan8214
    @jackykwan8214 2 года назад

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

  • @D3athW1ng
    @D3athW1ng 2 года назад

    fantastic

  • @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.

  • @turbowarsutube
    @turbowarsutube 2 года назад

    thanks man. this is so helpful...

  • @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.

  • @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

  • @eeeeeeeeebatitupalkata6011
    @eeeeeeeeebatitupalkata6011 6 месяцев назад +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  6 месяцев назад

      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 6 месяцев назад

      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 6 месяцев назад

      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

  • @peacekeeper9496
    @peacekeeper9496 Год назад

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

  • @crypto_peng
    @crypto_peng 2 года назад +1

    9:30 rerntramcy

  • @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

  • @user-ye6hk7rx2l
    @user-ye6hk7rx2l 2 года назад

    1080p?

  • @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