Makes a call to an smart contract method. Calls only fetch information from blockchain so it doesn't consume gas
Address or alias of the smart contract registered in Hancock
The name of the method to call
An array of arguments passed to the method
The address of the account doing the call
The returned value from the smart contract method
Makes an invocation to an smart contract method with abi. Invocations are used to call smart contract methods that writes information in the blockchain consuming gas
Address or alias of the smart contract registered in Hancock
The name of the method to call
An array of arguments passed to the method
The address of the account doing the call
raw in json format
The returned value from the smart contract method
Makes an invocation to an smart contract method. Invocations are used to call smart contract methods that writes information in the blockchain consuming gas
The address of the account doing the call
Configuration of how the transaction will be send to the network
Public URL where the .bin and .abi are
The name of the constructor to call
An array of arguments passed to the method
The returned value from the smart contract method
Get the list of all contracts registered in Hancock
The list of all contracts registered in Hancock
Makes an invocation to an smart contract method. Invocations are used to call smart contract methods that writes information in the blockchain consuming gas
Address or alias of the smart contract registered in Hancock
The name of the method to call
An array of arguments passed to the method
The address of the account doing the call
Configuration of how the transaction will be send to the network
The returned value from the smart contract method
Makes an invocation to an smart contract method with abi. Invocations are used to call smart contract methods that writes information in the blockchain consuming gas
Address or alias of the smart contract registered in Hancock
The name of the method to call
An array of arguments passed to the method
The address of the account doing the call
Configuration of how the transaction will be send to the network
raw in json format
The returned value from the smart contract method
Register a new smart contract instance in Hancock
An alias for the smart contract
The address of the deployed smart contract instance
The application binary interface (abi) of the deployed smart contract
The result of the request
Create a websocket subscription to watch transactions of type "smart contract transactions" in the network
An array of address that will be added to the watch list
A consumer plugin previously configured in hancock that will handle each received event
An event emitter that will fire the watched "smart contract transactions" events
Create a websocket subscription to watch transactions of type "smart contract events" in the network
An array of address of smart contracts that will be added to the watch list
A consumer plugin previously configured in hancock that will handle each received event
An event emitter that will fire the watched "smart contract events" events
Create a websocket subscription to watch transactions of type "smart contract transactions" in the network
An array of address of smart contracts that will be added to the watch list
A consumer plugin previously configured in hancock that will handle each received event
An event emitter that will fire the watched "smart contract transactions" events
Generated using TypeDoc
HancockEthereumSmartContractService
Introduction
We can use this interface to manage operations related with Ethereum smart contracts over blockchain
Smart contract deployment
const hancockEthClient = new HancockEthereumClient(config); const result = await hancockEthClient.smartContract.deploy( '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF', {privateKey: '0xd06026d5b8664036bdec0a924b8c7360566e678a2291e9440156365b040a7b83'}, 'https://s3-eu-west-1.amazonaws.com/ethereum/eip20/EIP20', 'EIP20', ['1000', 'HancockTest1', '18', 'HT1'] ); console.log(result);
Console output:
{ blockHash: '0x4c5dae42c9ea1b90912b6f7128a9d1213d14f70ca12b06f417b4d519b8cfe543'; blockNumber: 4460598; transactionId: '0x241dbc176195e58c7505812e7c9a04bd83c5dd59b0684e39911f88bedce5c6bf'; from: '0x8a37b79e54d69e833d79cac3647c877ef72830e1'; to: null; value: IHancockSocketCurrency; data: ''; fee: IHancockSocketCurrency; newContractAddress: '0x54a298ee9fccbf0ad8e55bc641d3086b81a48c41'; timestamp: 1559038793; }
Smart contract invoke
const hancockEthClient = new HancockEthereumClient(config); const result = await hancockEthClient.smartContract.invoke( 'token-contract-alias', 'balanceOf', ['0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF'], '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF', {privateKey: '0xd06026d5b8664036bdec0a924b8c7360566e678a2291e9440156365b040a7b83'} ); console.log(result);
Console output:
{ success: true, transactionHash: '0x241dbc176195e58c7505812e7c9a04bd83c5dd59b0684e39911f88bedce5c6bf' }
Subscribe to smart contract deployment
const hancockEthClient = new HancockEthereumClient(config); const subscription = hancockEthClient.smartContract.subscribeToDeployments([ '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF', ]); subscription.on(CONSUMER_EVENT_KINDS.SmartContractDeployment, (data) => { console.log(data) }); subscription.on(CONSUMER_EVENT_KINDS.Error, (error) => { console.error(error) });
Subscribe to smart contract transactions
const hancockEthClient = new HancockEthereumClient(config); const subscription = hancockEthClient.smartContract.subscribeToTransactions([ 'contract-alias', ]); subscription.on(CONSUMER_EVENT_KINDS.SmartContractTransaction, (data) => { console.log(data) }); subscription.on(CONSUMER_EVENT_KINDS.Error, (error) => { console.error(error) });
Subscribe to smart contract events
const hancockEthClient = new HancockEthereumClient(config); const subscription = hancockEthClient.smartContract.subscribeToEvents([ 'contract-alias', ]); subscription.on(CONSUMER_EVENT_KINDS.SmartContractEvent, (data) => { console.log(data) }); subscription.on(CONSUMER_EVENT_KINDS.Error, (error) => { console.error(error) });