Closed humanwhoexplores closed 3 years ago
let's understand it piece - by -piece
const ganache = require('ganache-cli'); const Web3 = require('web3'); const web3 = new Web3(ganache.provider()); const { interface, bytecode } = require('../compile')
i create a object of 'ganache'
I create a object of web3 : While creating this i refer "Ganache Provider".
if you want to read a doc on how we declare web3 Object : -
https://web3js.readthedocs.io/en/v1.2.11/web3.html#web3-instance
inbox = await new web3.eth.Contract(JSON.parse(interface)) .deploy({data : bytecode, arguments: ['Inbox contract']}) .send({from: accounts[0], gas: '1000000'})
This is the one line that deploys the contract on Test Network. The attributes being used are :-
Basically there are 2 different entities
To link Deployment N/w and Web3 we need a bridge ; this bridge is the provider.
![Uploading Screenshot 2021-09-25 at 1.21.47 PM.png…]()
![Uploading Screenshot 2021-09-25 at 1.35.59 PM.png…]()
Complete Code :