We want to connect the people who have knowledge to the people who need it, to bring together people with different perspectives so they can understand each other better, and to empower everyone to share their knowledge.
// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; contract Migrations { string public _message; uint public _last_completed_migration; function Hello() public{ _message = "Hello World!"; } function setCompleted(uint completed) public { _last_completed_migration = completed; } function message() public view returns(string memory) { return _message; } function lastCompletedMigration() public view returns (uint) { return _last_completed_migration; } }
let contract = await Migrations.deployed() contract.Hello() contract.message()
{ "name": "eth-webb3js", "version": "1.0.0", "dependencies": { "fs": "0.0.1-security", "web3": "^1.6.0" }, "scripts": { "start": "node main.js" } }
const Web3 = require('web3'); const fs = require('fs'); let provider = new Web3.providers.HttpProvider("http://localhost:8545/"); let web3 = new Web3(provider); web3.eth.defaultAccount = "0xa9f6009507ef930c67b98f7a12cb0ca4321aaadb"; // change by your contract address not account address let contractJson = fs.readFileSync("../truffle/build/contracts/Migrations.json").toString().trim(); let abi = JSON.parse(contractJson).abi; web3.eth.personal.unlockAccount("0x3c31b4b9d6c24bad29498f99aaa6914231362c7f", "123", 600) // change by your account address .then(console.log('Account unlocked!')); let contract = new web3.eth.Contract(abi, web3.eth.defaultAccount); contract.methods.Hello().call().then(console.log); contract.methods.message().call().then(console.log);
> node main.js Account unlocked! Result {} Hello World!
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Input your email to receive reset password link, or if you remember your password, you can click