github.com/shyftnetwork/go-empyrean@v1.8.3-0.20191127201940-fbfca9338f04/shyft-config/shyft-cli/web3/deployContract.js (about) 1 var _message = "Hello" ; 2 var inboxContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"_newMessage","type":"string"}],"name":"setMessage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"message","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_message","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_newMessage","type":"string"}],"name":"EventMessage","type":"event"}]); 3 var inbox = inboxContract.new( 4 _message, 5 { 6 from: web3.eth.accounts[0], 7 data: '0x6060604052341561000f57600080fd5b604051610454380380610454833981016040528080518201919050508060009080519060200190610041929190610048565b50506100ed565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061008957805160ff19168380011785556100b7565b828001600101855582156100b7579182015b828111156100b657825182559160200191906001019061009b565b5b5090506100c491906100c8565b5090565b6100ea91905b808211156100e65760008160009055506001016100ce565b5090565b90565b610358806100fc6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063368b877214610048578063e21f37ce146100a557600080fd5b341561005357600080fd5b6100a3600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610133565b005b34156100b057600080fd5b6100b86101e9565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f85780820151818401526020810190506100dd565b50505050905090810190601f1680156101255780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b8060009080519060200190610149929190610287565b507f2ec385c52f10e65de137fbbeb2582bb0f4a8460a2163012971e923d179d73ea7816040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ac578082015181840152602081019050610191565b50505050905090810190601f1680156101d95780820380516001836020036101000a031916815260200191505b509250505060405180910390a150565b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561027f5780601f106102545761010080835404028352916020019161027f565b820191906000526020600020905b81548152906001019060200180831161026257829003601f168201915b505050505081565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106102c857805160ff19168380011785556102f6565b828001600101855582156102f6579182015b828111156102f55782518255916020019190600101906102da565b5b5090506103039190610307565b5090565b61032991905b8082111561032557600081600090555060010161030d565b5090565b905600a165627a7a72305820c83fcf90975f9c6996cf8dde1a2a1f4fab1f408588a2f8587487833ac98665630029', 8 gas: '4700000' 9 }, function (e, contract){ 10 if(!e) { 11 // NOTE: The callback will fire twice! 12 // Once the contract has the transactionHash property set and once its deployed on an address. 13 // e.g. check tx hash on the first call (transaction send) 14 if(!contract.address) { 15 console.log("TX hash:") 16 console.log(contract.transactionHash) // The hash of the transaction, which deploys the contract 17 18 } else { 19 console.log("Contract address:") 20 console.log(contract.address) // the contract address 21 contract.methods.setMessage('New').call({from: web3.eth.accounts[0]}, function(error, result){ 22 if (error) { 23 console.log(error) 24 } else { 25 console.log('[METHOD RESULT]: ', result) 26 } 27 }); 28 } 29 30 } 31 });