DEV Community

Amy's Vue on this
Amy's Vue on this

Posted on

1 1

Web3 Solidity + JavaScript 32 hour course recap #14

timestamps 4:33:33 - 4:50:26

As an aside, I applied for the gitcoin grant program, and then pretty much immediately had to put this training on hiatus. I was launching my new website (Banned Books Art)[https://www.bannedbooks.art]. It's a VR art gallery that advocates for free speech, and I decided to make the VR from scratch using the A-Frame library. It was a lot of work, and there's still some cleanup, but overall the launch went well.

So this is more of a review than usual for me....

Anyways, the first thing we did was go to a previous version of Solidity to demonstrate what safe numbers are. It's a little wild that we could accidentally reset everything to zero before Solidity 8.

The unchecked keyword makes our code a little bit more gas efficient.

We instantiated a pretty standard for loop to reset the funders after we withdraw the funds.

for (uint256 i = 0; i < funders.length; i++) {}

which, I know how to do from basic javascript, but that's a little old school for JS, and we now favor forEach, entries, and mappings.

We also reset the array like this: funders = new address[](0);

Arrays can be tricky when you don't actually assign them as new objects, so this makes sense that we're setting it to a new array with 0 elements - which makes it empty.

Apparently we went over 3 ways to Ethereum to a wallet, but the third way is to use the call statement. Which is the preferred method in version 8+.

(bool callSuccess, ) = payable(msg.sender).call{value: address(this).balance}("");
require(callSuccess, "Call Failed");

I'm going to wind up rewatching this portion because I'm pretty sure the ("") is because we don't actually have a callback function that we want to use. We're only checking on the balance.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay