Last active
March 29, 2018 08:00
-
-
Save pdyakov/cc9b2454dece1b5cf780b123c55d6e7e to your computer and use it in GitHub Desktop.
Etherium Blockchain Platform Quick Start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to connect to Etherium Blockchain Platform | |
// Emitting events and listening for events within blockchain network | |
var Web3 = require('web3'); | |
const HOST = ''; | |
const ACCOUNT = ''; | |
const ContractData = {...}; | |
// Connection | |
var provider = new Web3.providers.HttpProvider(HOST); | |
var web3 = new Web3(provider); | |
web3.eth.defaultAccount = ACCOUNT; | |
// Initializing contract | |
var contract = web3.eth.contract(ContractData.ABI); | |
var contractInstance = contract.at(ContractData.address); | |
// Emitting event | |
contractInstance.emitEvent(ACCOUNT, 'data', 'some_hast', { gas: 200000 }); | |
// Listening events | |
contractInstance.allEvents().watch(function(error, event) { | |
// Received event | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment