Try   HackMD

Day 2

Writing web 3

Learn to write contracts that control money, identity and ownership.


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More β†’
The goal for today is to write contracts that compile.
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More β†’


Make sure you clone every repository and build it locally. Getting each application running is as important as reading the code because today you will be focused on understanding how all the moving parts work.

If you get stuck on one application for some reason, just ask for help in Discord and MOVE ON immediately. If possible, don't wait for someone to reply before you continue or you will lose time.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More β†’
CORE Activities

In the Resources section below choose AssemblyScript or Rust

  • REVIEW all 3 applications labeled as CORE Activity for your language

If you prefer to have specific steps, you could do something like this to study each contract or dApp carefully:

  1. Pick any contract from Day 1 (see Day 1 page) or dApp from Day 2 (see below)
  2. Clone the repo locally (or in Gitpod if using Windows)
  3. Make sure you can find the contract source code and that you can compile the contract to a .wasm file
  4. Test the contract somehow so you know it's working. You can do this using NEAR CLI commands or by running existing unit or simulation tests, or even by using a web interface if the dApp has one. The KEY idea here is to make sure you will NOTICE a change to the contract if you make one
  5. Make any small change to the contract. Not a big change, but something simple.
  6. Rebuild and retest (repeat steps 3 & 4)
  7. Did the change you made work as expected? Or did you break something?
  8. Ask for help if you need it
  9. Keep repeating 6-7-8 until your confidence increases… until you believe you understand the contract and can control it
  10. Delete the contract and write it again from your notes (you took notes right?). You can also just rewrite small parts of the contract, of course.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More β†’
BONUS Activities

If you have the time to look around the corner, here's a little more for you.

The more applications you see, the more ideas you will have about what is possible with NEAR.

  1. Read through ALL the applications for your language of choice, not just 3

  2. Read through all the applications from the OTHER language as well.

  3. Check out this little puzzle, it may be fun for you

  4. Write a script in your favorite language that automates some of the tedious bits. You will find some inspiration among the other projects you've already seen.

    • compiling a contract
    • deploying (and optionally initializing) a contract
    • exercising contract methods

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More β†’
Going Deeper

If you're feeling fearless, here's about as far as you might take this road in a day

AssemblyScript

  • Complete these challenges in the AssemblyScript workshop

  • Complete this challenge then modify the contract in some interesting ways

  • Review some of NEAR's data "convenience" structures. These are all wrappers for NEAR Storage as seen in docs

  • Review Fungible and Non-fungible Token contracts in AssemblyScript

Rust


To call methods, and methods, and methods, signing transactions in this petty pace from day to day, to the last token of recorded block height;

And all our ledgers have hard forked on their way to a dusty death. Out, out, brief consensus!

web 3's but a walking shadow, a poor player, that struts and frets his hour upon the internet, and then gossips no more.

It is a tale told by a HODLer, full of sound and fury, signifying nothing.

– Willmoon Shakeschain


Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More β†’
Resources

REMEMBER: For today's activity

  • You DO need to build (and run tests, if available for) each dApp ("decentralized app")
  • You should TRY to understand EVERY line of code in the contract

AssemblyScript

If you intend to focus on AssemblyScript, [ OPEN the list of dApps using AssemblyScript ]

You should review a minimum of 3 applications marked as CORE Activity.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More β†’

Rust

If this is your first time using Rust on your computer, please follow this Intro to Rust in our docs. The "3-Step Rust Installation" will help you install the required software.

If you intend to focus on Rust, [ OPEN the list of dApps using Rust ]

You should read a minimum of 3 applications marked as CORE Activity.

You can read more about Rust contract basics as well.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More β†’

No Contract

It's possible to build applications with NEAR that do not use a contract.

Here are some examples of these: [ OPEN the list of apps using NO CONTRACT ]

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More β†’