metamask-docs icon indicating copy to clipboard operation
metamask-docs copied to clipboard

Update beginner's tutorial

Open joaniekube opened this issue 1 year ago • 9 comments

Description

Deprioritizes the current detect provider and added basic tutorial in vanilla JS without EIP-6963

Issue(s) fixed

Fixes #1202

Preview

https://docs.metamask.io/1202-tutorial/wallet/tutorials/javascript-dapp-simple/

Checklist

Complete this checklist before merging your PR:

  • [x] If this PR contains a major change to the documentation content, I have added an entry to the top of the "What's new?" page.
  • [ ] The proposed changes have been reviewed and approved by a member of the documentation team.

joaniekube avatar Apr 18 '24 21:04 joaniekube

Preview published: 1202-tutorial

github-actions[bot] avatar Apr 22 '24 18:04 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar Apr 22 '24 18:04 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar Apr 23 '24 19:04 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar Apr 23 '24 20:04 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar Apr 23 '24 20:04 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar Apr 23 '24 22:04 github-actions[bot]

@vandan PTAL

joaniekube avatar Apr 26 '24 13:04 joaniekube

Preview published: 1202-tutorial

github-actions[bot] avatar Apr 26 '24 13:04 github-actions[bot]

I think that this works and illustrates detecting and connecting to metamask in a bare bones simple dapp.

My only suggestion is to maybe ... start with Vite Vanilla JS app using:

npm create vite@latest simple-dapp -- --template vanilla

This would create the structure of the dapp for them.

Next step could be to rename the counter.js or add a detect.js file to the project and then follow the rest of the steps.

This keeps the tutorial user form having to configure webpack and utilizes ViteJS which we have been trying to leverage in our other tutorials.

This is something that if we want, I could make a change to the branch to implement. If we think it is not needed, I'm ok with the current PR.

Steps in a ViteJS would be:

  1. npm create vite@latest simple-dapp -- --template vanilla
  • OUTPUT:
Scaffolding project in /Users/eric/src/github/metamask/test/simple-dapp...

Done. Now run:

  cd simple-dapp
  npm install
  npm run dev
  1. Add a detect.js file that replaces the index.js file in this tutorial (favoring better naming)
  2. Update HTML to:
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite App</title>
  </head>
  <body>
    <div id="app">
      <!-- Display a connect button and the current account -->
      <button class="enableEthereumButton">Enable Ethereum</button>
      <h2>Account: <span class="showAccount"></span></h2>
    </div>
    <script type="module" src="/detect.js"></script>
  </body>
</html>

Javascript steps remain the same.

httpJunkie avatar May 02 '24 16:05 httpJunkie

Preview published: 1202-tutorial

github-actions[bot] avatar May 08 '24 20:05 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar May 09 '24 18:05 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar May 31 '24 00:05 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar May 31 '24 01:05 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar May 31 '24 05:05 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar May 31 '24 07:05 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar May 31 '24 07:05 github-actions[bot]

Preview published: 1202-tutorial

github-actions[bot] avatar May 31 '24 16:05 github-actions[bot]

Made some edits, including updating the full example JS code to match the code provided in the tutorial steps. LGTM.

Thank you @alexandratran

joaniekube avatar May 31 '24 16:05 joaniekube