Closed humanwhoexplores closed 3 years ago
Now : to deploy the code I need a Test Ether account :- Bro : i can't use my primary account so i will make a new Metamask Account and play with it.
Added deploy.js in this commit https://github.com/humanwhoexplores/smart-contracts/commit/ba86e11888e8add4eeec4d65bf8c6bb0e1c8d41d
the code that deploys the contract
`const HDWalletProvider = require("truffle-hdwallet-provider"); const Web3 = require("web3"); const { interface, bytecode } = require("./compile");
var mnemonic = 'MNEMONIC PLEASE; var infura_provider_url = 'https://rinkeby.infura.io/v3/7985ca9520d8459b9XXXXXXXXXXXXXX';
const provider = new HDWalletProvider( mnemonic, infura_provider_url);
const web3 = new Web3(provider);
const deploy = async () => { const accounts = await web3.eth.getAccounts();
console.log("All the accounts we got are ", accounts); console.log("Attempting to deploy from account", accounts[0]);
let balance = await web3.eth.getBalance(accounts[0]); console.log("The balance is ", balance);
const result = await new web3.eth.Contract(JSON.parse(interface)) .deploy({ data: bytecode, arguments: ["Hi there!"] }) .send({ gas: "1000000", from: accounts[0] });
console.log("Contract deployed to", result.options.address); }; deploy(); `
The mnemonic is of my Test MetaMask Account infura_provider_url :- endpoint of my infura api project
─$ node deploy.js All the accounts we got are [ '0x27E03B595852f40253Af8f9905ecDe40552b5496' ] Attempting to deploy from account 0x27E03B595852f40253Af8f9905ecDe40552b5496 The balance is 18489104207993164656 Contract deployed to 0x847611615F036877fad9B17446D90004FB7F6B92
Link to Rinkeby Etherscan https://rinkeby.etherscan.io/tx/0x22854d36702bb8da4135c8cad4ad7bab74bc666153287abb4ed7ac1f3d2ad13c