Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Web3 = require("web3");
- const fs = require("fs");
- const solc = require("solc");
- var web3 = new Web3('ws://localhost:7545');
- // Compile the source code
- const input = fs.readFileSync('helloworld.sol');
- const output = solc.compile(input.toString(), 1);
- const bytecode = output.contracts[':Greeter'].bytecode;
- const abi = JSON.parse(output.contracts[':Greeter'].interface);
- var options = {
- data: '0x' + bytecode,
- from: '0xB922118304784e9EbA04700Be74798e33B331590',
- gas: 90000*2
- };
- var jsonint = [{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"payable":false,"type":"constructor"}];
- // Contract object
- const contract = new web3.eth.Contract(jsonint, options);
- console.log(contract.options.data);
- const cb = (newContractInstance) =>
- {
- console.log(newContractInstance.options.address) // instance with the new contract address
- newContractInstance.methods.greet().call({from:'0xB922118304784e9EbA04700Be74798e33B331590'}, function(error, result){
- console.log(result);
- });
- }
- contract.deploy({arguments:['Hello, World!']})
- .send({
- from: '0xB922118304784e9EbA04700Be74798e33B331590',
- gas: 1500000,
- gasPrice: '30000000000000'
- })
- .then(cb);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement