Blockchain connector is deprecated - please use Squeezer ChainKit
squeezer-blockchain-connector
Agnostic blockchain connector
The main scope for adding the connector is to unify all the current blockchains data assets into a single normalized API interface , therefore you can build blockchain apps easily without digging into all blockchain infrastructures
Basically the connector is only a client for the Squeezer Blockchain Gateway where actually all the magic happens.
Check the Squeezer Blockchain Gateway API Documentation:
Squeezer Blockchain Gateway - Test
Squeezer Blockchain Gateway - Production (in development)
Table of contents
Install
npm install squeezer-blockchain-connector --save
Initialize
You will need a Squeezer access key in order to use the blockchain connector. You can get one here
const BlockchainConnector = ;const blockchainConnector = options;
options
requiredoptions.accessKey
- required Squeezer access keyoptions.environment
- required usetest
for sandbox orlive
for production
ITN ( Instant Transaction Notification )
The ITN system will notify your server when you receive a transaction and when a transaction status changes. This is a quick and useful way to integrate blockchain transactions processing.
Please check the Squeezer Blockchain Gateway API Documentation
->Configure ITN callback url
ITN JSON object:
{ "from": "0xc03f7B9bddF8aeeBCbA2f818E5f873f71b85EB5c", "to": "0x903f7B9bddF8aeeBCbA2f818E5f873f71b85EB5c", "amount": "0.99999999", "type": "in", "currency": "ETH", "accessKeyHash": "accessKeyHash", "hash": "0xcf387e8d1a95bd3a5b54269aa0a228...", "block": "891093", "status": 1, "itnStatus": 1, "createdAt": "2018-05-13 18:09:18", "updateAt": "2018-05-13 18:09:18"}
NOTE: As a security measure please make sure that you validate accessKeyHash
is the same at with your default access key
Validate accessKeyHash
example:
if accessKeyHash === crypto console else console
Wallet types
Get current available blockchain wallet types
blockchainConnector
callback
- required callback function, accepts 2 values (error
,result
)
Example request
blockchainConnector;
Example response from server
Create wallet
Create a new blockchain wallet.
blockchainConnector
options
- required.options.type
- required. Wallet type (ETH
).callback
- required callback function, accepts 2 values (error
,result
)
Example request
blockchainConnector;
Example response from server
NOTE: Squeezer will not store any sensitive data similar to token
. For later usage please store the wallet details on a secure & safe environment.
Send transaction
Initiate a new blockchain transaction.
blockchainConnector
options
- required.options.amount
- required. Amount to send, 8 decimal max. (0.01
).options.type
- required. Transaction type. (ETH
).options.to
- required. Receiver's addressoptions.token
- required. Wallet tokencallback
- required callback function, accepts 2 values (error
,result
)
Example request
blockchainConnector;
Example response from server
Get transactions
Get transactions for a specific wallet
blockchainConnector
options
- required.options.walletId
- required. Wallet IDcallback
- required callback function, accepts 2 values (error
,result
)
Example request
blockchainConnector;
Example response from server
Get balance
Get balance for a specific wallet
blockchainConnector
options
- required.options.walletId
- required. Wallet IDcallback
- required callback function, accepts 2 values (error
,result
)
Example request
blockchainConnector;
Example response from server
Smart contract ( In development feature )
Access a smart contract
blockchainConnector
options
- required.options.address
- required. Smart contract address.options.type
- required. Smart contract type. (ETH
)options.abi
- required. Abi code.options.methods
- required. Smart contract methods.options.token
- required. Wallet tokencallback
- required callback function, accepts 2 values (error
,result
)
Example request
blockchainConnector;