자바스크립트를 사용한 Web3.js
3467 단어 web3javascripttutorialblockchain
Course Overview
- Web3.js ** web3.js is a collection of libraries that allow you to interact with a local or remote ethereum node using HTTP, IPC or WebSocket.** 2.** Modules**
- Uses we can transfer ether in the wallet
- We can fetch the account balance 3.Web3.js in chrome console 4.We generate ABI and ByteCode using Web3.js in our smart contract 5.Compilation of Web3.js 6.Deployement of Smart Contract *Web3.js Prerequisites *
- Blockchain
- Basic understanding of Blockchain
- Ethereum
- Basic understanding of Ethereum
- Solidity
- Basic idea about Solidity
- JavaScript
- Basic understanding of JavaScript Software Requirement
- Node js
- Ganache
- Vs Code
What is Web3.js?
- Suppose we have a application and we want to connect our application with blockchain(Smart Contract),then we can use Web3.js in our applications to connect to the blockchain(Smart Contract).
- It acts as a interface between your peer world(application) and blockchain (Smart Contract).
- Web3.js is nothing but the interactions between our application and Smart Contract in Blockchain Web3.js
- Installation of Web3.js
- Import of Web3.js
- To connect with Ganache
- To get the balance of an account
- to convert wei into ether
to transfer ether from one account to another account
Steps to proceednode --v
npm init -y
npm install --save web3
let Web3 = require('web3');
//to check web3 is import or not
console.log(" Web3", Web3);
//Now we will create a object named web3
let web3=new Web3(new Web3.providers.HttpProvider("Please give ganache url");
이제 우리는 가나슈를 제어할 수 있습니다
web3.eth.getBalance("id of account").then(console.log);
//you will get the balance of the account
//you need to have a little understanding of javascript
//then can also acts as a Promise
//if we want to get the balance
web3.eth.getBalance("id of account").then(function(result){
console.log(web3.utils.fromWei(reults,"ether"));});
});
어떻게 한 계정에서 다른 계정으로 이더를 전송할 수 있습니까?
web3.eth.sendTransactions({from:" id of account where money need to be transfer",to:"id of account where money need to be sent",value:web3.utils.toWei("Amount to be transfer","ether")});
모든 리소스의 기본 소스는 click here입니다.
읽어 주셔서 감사합니다
Reference
이 문제에 관하여(자바스크립트를 사용한 Web3.js), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/kaustavkarmakar2/web3js-with-javascript-26n1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)