/deploy-smart-contract-web3

Deploy a contract using web3.js

Primary LanguageJavaScript

Deploy a contract using web3.js

Create a simple smart contract and use the Web3 JavaScript library to compile and then deploy the smart contract base on Infura that

  • Provides world-class infrastructure for developers to ensure their decentralized application scales to meet user demand.
  • Focuses on making blockchain development a simple, cohesive experience with all of your tools in one place: Ethereum Nodes, Eth2 Nodes, Transaction Relaying, Layer 2 Networks, IPFS, and Filecoin.

Prerequisites

Install dependencies libraries

npm install

Update environment variables in file .env

ETHEREUM_NETWORK = "ropsten"
INFURA_PROJECT_ID = "<Your-Project-ID>"
SIGNER_PRIVATE_KEY = "<Your-Private-Key>"

Generate Application Binary Interfaces ABI file if you want to modifie (Optional)

node compile.js

Deploy contract and get conract address

node deploy.js

Update contract address in your .env

ETHEREUM_NETWORK = "ropsten"
INFURA_PROJECT_ID = "<Your-Project-ID>"
SIGNER_PRIVATE_KEY = "<Your-Private-Key>"
DEMO_CONTRACT = "<Contract_Address>"

Execute a function in a smart contract

node call.js

Execute the transaction

node sendTx.js