Let’s create a simple example smart contract just to see things end-to-end before we start experimenting:

clevis create SomeContract

Let’s add a name field just as a test that everything is working right.

clevis compile SomeContract clevis deploy SomeContract 0 clevis test publish

This turns our contract into bytecode, deploys it to our local blockchain, and injects the ABI into our Dapp. Let’s make a few edits to the Dapp so we can employ the contract loader to bring in our contract:

Rad so there is our name from the contract in the Dapp. We are wired up!

Let’s slowly walk through a few neat concepts with smart contracts. First, let’s create a function that lets us set the name:

We’ll add some UI in the Dapp to let us set the name:

And a hook in the Dapparatus onUpdate to update our name :

I always forget, but if you are using await you need to add async to the function.

Cool! So now we can read and write from the contract!

Let’s dive into why programmable money is so powerful. Let’s make users pay to update the name.

We’ll make the function payable and require that they put in more than the last person:

Then compile and deploy the update:

clevis test full

And add some UI to allow the user to put in and send value in the transaction:

Neat! Works!

Okay finally we want to be able to withdraw the ETH but only as the owner:

clevis test full

Now we can withdraw the ETH from the command line as the owner that deployed the contract:

clevis contract withdraw SomeContract 0

RAD.

So we’ve learned about payable functions, tracking msg.sender , tracking msg.value , and requiring certain situations. But what about that signed message?

Okay, You’ll want to dive in and read more about the ecrecover() function. It can do that recover on-chain and that opens up a whole new world for onboarding and usability when users can just sign messages and they don’t need ETH or gas or MetaMask!

I would start with my Native Meta Transactions tutorial.

Next in a long line of tools you might use is the Open Zeppelin contracts. I have a great tutorial for creating a shitcoin, but basically you can just bring in the OZ contracts and set your symbol and deploy:

What about randomness? This is hard on chain, but I have a tutorial on commit/reveal here!

Conclusion

There is so much great content out there for Ethereum developers. Google is your friend, but I’m always here too! Hit me up @austingriffith everywhere!