Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 17, 2024. It is now read-only.
NotificationsYou must be signed in to change notification settings

PatrickAlphaC/ethers-simple-storage-fcc

Repository files navigation

ℹ️ Important: This repo is no longer maintained; we invite all people learning Solidity to head toCyfrin Updraft! The 100% free #1 smart contract education platform on earth. Developed with love by Patrick & Cyfrin <3

Ethers Simple Storage

This is part of the FreeCodeCamp Solidity & Javascript Blockchain Course.

Video Link :⌨️ (05:30:42) Lesson 5: Ethers.js Simple Storage

Getting Started

Requirements

  • git
    • You'll know you did it right if you can rungit --version and you see a response likegit version x.x.x
  • Nodejs
    • You'll know you've installed nodejs right if you can run:
      • node --version and get an ouput like:vx.x.x
  • Yarn instead ofnpm
    • You'll know you've installed yarn right if you can run:
      • yarn --version and get an output like:x.x.x
      • You might need to install it with npm
  • ganache
    • You'll know you did it right if you can run the application and see:
      ganache
    • You can alternatively useganache-cli orhardhat

Optional Gitpod

If you can't or don't want to run and install locally, you can work with this repo in Gitpod. If you do this, you can skip theclone this repo part.

Open in Gitpod

Setup

Clone this repo

git clone https://github.com/PatrickAlphaC/ethers-simple-storagecd ethers-simple-storage

Then install dependencies

yarn

Note: You'll notice in ourpackage.json we are using"solc": "0.8.7-fixed". Usually, you'll just be able to do"solc": "0.8.7" to get a specific version, but there was a bit of an issue with that one... You'll find out why we use 0.8.7

Typescript

If you liketypescript, rungit checkout typescript then runyarn

Usage

  1. Run your ganache local chain, by hittingquickstart on your ganache application

Save the workspace. This way, next time you open ganache you can start the workspace you've created, otherwise you'll have to redo all the steps below.

  1. Copy theRPC SERVER sting in your ganache CLI, and place it into your.env file similar to what's in.env.example.

ganache

.env Example:

RPC_URL=http://0.0.0.0:8545
  1. Hit the key on one of the accounts, and copy the key you see and place it into your.env file, similar to what you see in.env.example.

ganache

ganache

.env Example:

PRIVATE_KEY=11ee3108a03081fe260ecdc106554d09d9d1209bcafd46942b10e02943effc4a

  1. Compile your code

Run

yarn compile

You'll see filesSimpleStorage_sol_SimpleStorage.abi andSimpleStorage_sol_SimpleStorage.bin be created.

  1. Run your application
node deploy.js

For WSL users

  1. Run
yarn add ganache
  1. Change Server settings in Ganache

Settings > Server > Host Name

Change Host Name to vEthernet (WSL)

  1. Run your application
node deploy.js

Deploying to a testnet

Make sure you have ametamask or other wallet, and export the private key.

IMPORTANT

USE A METAMASK THAT DOESNT HAVE ANY REAL FUNDS IN IT. Just in case you accidentally push your private key to a public place. Ihighly recommend you use a different metamask or wallet when developing.

  1. Export your private key and place it in your.env file, as done above.

  2. Go toAlchemy and create a new project on the testnet of choice (ie, Sepolia)

  3. Grab your URL associated with the testnet, and place it into your.env file.

  4. Make sure you havetestnet ETH in your account. You canget some here. You should get testnet ETH for the same testnet that you made a project in Alchemy (ie, Sepolia)

  5. Run

node deploy.js

Troubleshooting: Ethers 6.X.X instability

constprovider=newethers.providers.JsonRpcProvider(process.env.RPC_URL)^TypeError:Cannotreadpropertiesofundefined(reading'JsonRpcProvider')

If you are experiencing issues with the latest version of Ethers, ethers ^6.0.2, try

constprovider=newethers.JsonRpcProvider(process.env.RPC_URL)

as providers were migrated to ethers.* in version 6 (previously ethers.providers.*).reference:https://docs.ethers.org/v6/migrating/#migrate-providers

Or you can easily solve the problem by downgrading to a previous version of Ethers, such as ethers 5.7.2.

To downgrade to ethers 5.7.2, run either of the following commands on your command line interface, depending on your package manager:

For npm:

npm install ethers@5.7.2

For yarn:

yarn add ethers@5.7.2

Thank you!

If you appreciated this, feel free to follow me or donate!

ETH/Polygon/Avalanche/etc Address: 0x9680201d9c93d65a3603d2088d125e955c73BD65

Patrick Collins TwitterPatrick Collins YouTubePatrick Collins LinkedinPatrick Collins Medium

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp