Hancock SDK client
Using this package
Dependencies
This lib depends on ES6 Promises that are native in node. But you have to polyfill it in some browsers using es6-promise
package.
Installation
Once you have access to the kst registry:
npm install --save es6-promise @hancock/sdk-nodejs
yarn add es6-promise @hancock/sdk-nodejs
Using all together
The main client is the HancockEthereumClient class. You have to instantiate it passing an HancockConfig configuration object
to indicate the client which hancock service it has to use.
Configuration object example:
const config = {
adapter : {
host : 'http://localhost' ,
port : '3000' ,
base : '/'
},
wallet : {
host : 'http://localhost' ,
port : '3000' ,
base : '/'
},
broker : {
host : 'ws://localhost' ,
port : '3000' ,
base : '/'
}
}
require ('es6-promise' ).polyfill();
const HancockEthereumClient = require ('@hancock/sdk-nodejs' ).HancockEthereumClient
new HancockEthereumClient(config);
We need to include the ethereumjs-tx module as an external deependency before the sdk:
<script src ="https://raw.githubusercontent.com/ethereumjs/browser-builds/master/dist/ethereumjs-tx/ethereumjs-tx-1.3.3.min.js" > </script >
And then use the sdk as an ES6 module (or in module bundlers like webpack)
import * as es6Promise from 'es6-promise' ;
es6Promise.polyfill();
import { HancockEthereumClient } from '@hancock/sdk-nodejs' ;
new HancockEthereumClient(config);
Introduction and examples
HancockEthereumClient provides interfaces to interact with the blockchain
allowing common operation like transfers, balance consulting or smart contract interactions. Take a look at the diferent sections of the docs to see examples of use:
Type aliases
DltAddress
DltAddress: string
Defined in services/hancock.model.ts:6
DltRawTransaction
DltRawTransaction: any
Defined in services/hancock.model.ts:7
DltSignedTransaction
DltSignedTransaction: string
Defined in services/hancock.model.ts:8
EthereumAbi
EthereumAbi: any []
Defined in services/ethereum/model.ts:12
EthereumAddress
EthereumAddress: string
Defined in services/ethereum/model.ts:3
EthereumBlockHash
EthereumBlockHash: string
Defined in services/ethereum/model.ts:6
EthereumContractAddress
EthereumContractAddress: string
Defined in services/ethereum/model.ts:4
EthereumContractEventStatus
EthereumContractEventStatus: "mined" | "pending"
Defined in services/ethereum/model.ts:9
EthereumContractLogId
EthereumContractLogId: string
Defined in services/ethereum/model.ts:10
EthereumData
EthereumData: string
Defined in services/ethereum/model.ts:7
EthereumRawTransaction
Defined in services/ethereum/signer.ts:16
EthereumSignedTransaction
Defined in services/ethereum/signer.ts:17
EthereumTopic
EthereumTopic: string
Defined in services/ethereum/model.ts:8
EthereumTxHash
EthereumTxHash: string
Defined in services/ethereum/model.ts:5
HancockAdapterConfig
Defined in services/hancock.model.ts:240
HancockBrokerConfig
Defined in services/hancock.model.ts:242
HancockEventBody
Defined in services/hancock.model.ts:325
HancockEventKind
HancockEventKind: "error" | "event" | "logs" | "tx"
Defined in services/hancock.model.ts:324
HancockInvokeAction
HancockInvokeAction: "send" | "call"
Defined in services/hancock.model.ts:405
HancockProtocolAction
HancockProtocolAction: "transfer"
Defined in services/hancock.model.ts:277
HancockProtocolDlt
HancockProtocolDlt: "ethereum"
Defined in services/hancock.model.ts:278
HancockSignerFn
HancockSignerFn: function
Defined in services/hancock.model.ts:16
HancockSocketBody
HancockSocketBody: any
Defined in services/hancock.model.ts:446
HancockSocketStatus
HancockSocketStatus: "pending" | "mined"
Defined in services/hancock.model.ts:445
HancockWalletHubConfig
Defined in services/hancock.model.ts:241
InitialHancockAdapterConfig
InitialHancockAdapterConfig: InitialHancockServiceBaseConfig
Defined in services/hancock.model.ts:262
InitialHancockBrokerConfig
InitialHancockBrokerConfig: InitialHancockServiceBaseConfig
Defined in services/hancock.model.ts:266
InitialHancockWalletHubConfig
InitialHancockWalletHubConfig: InitialHancockServiceBaseConfig
Defined in services/hancock.model.ts:264