Deploying a Smart Contract
Explore how to deploy smart contracts to the Ethereum Goerli test network using web3.js and Infura. Learn to create and configure a JavaScript project, read contract bytecode and ABI, sign transactions, and send them to the network. This lesson helps you gain practical skills for interacting with Ethereum programmatically, preparing you for advanced dapp development.
We'll cover the following...
Now, we have everything we need to write an application that will deploy our smart contract to the Goerli network. In this lesson, we'll write a script in JavaScript that'll use the web3.js library to interact with the Goerli network through Infura. While the applications we will build in this chapter will be straightforward, we can use the same principles to create more complex applications that use the Web3 API.
Creating a project
To start working on our application, we first need to create a JavaScript project and add dependencies to it. To create a new project, we'll run the npm init command:
npm init -y
This command will generate a new package.json file containing information about our project, including its dependencies. We also add the -y flag that instructs npm to use default settings instead of prompting us about how to configure our project.
Having created a JavaScript project, we can now download dependencies for our project using the following npm install command:
npm install web3 dotenv
For this demo, we only need two dependencies:
web3: This is a package for the web3.js ...