Send ethers between two accounts
The sender address
The receiver address
The amount of ether to transfer (in weis)
Configuration of how the transaction will be send to the network
Extra information that will be sent with the transfer (a remark for example)
An event emmiter that will fire the watched "transfers" events
Create a websocket subscription to watch transactions of type "transfers" 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 emmiter that will fire the watched "transfers" events
Generated using TypeDoc
HancockEthereumTransferService
Introduction
We can use this interface to manage transfers of ether over blockchain
Send transfer
const hancockEthClient = new HancockEthereumClient(config); const result = await hancockEthClient.transfers.send( '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF', '0x28a0686efb7dd9b625288a08649a6278cc4fd154', 1000000000000000000, { privateKey: '0xd06026d5b8664036bdec0a924b8c7360566e678a2291e9440156365b040a7b83' } ); console.log(result);
Console output:
{ success: true }
Subscribe to transfers
const hancockEthClient = new HancockEthereumClient(config); const subscription = hancockEthClient.transfers.subscribe([ '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF' ]); subscription.on('tx', (data) => { console.log(data) }); subscription.on('error', (error) => { console.error(error) });