Kblib is a library designed to help with development on the kanban network, whether it is to interface with a kanban node, or to perform some common offline tasks such as signing transactions.
Kblib is made up of two main parts:
- Kblib.kanban - Involves interfacing with a kanban network. Requires a kanban node to connect to.
- Kblib._extend - Offline tools common for wallet and dapp development (not requiring a kanban node). Subdivided into sections called offline/utils/coders.
Set-up and Transaction Signing Example
const Kblib = require('./kblib');
const kblib = new Kblib();
// Offline methods - ready to go out of the box. Example creates a sendtocontract transaction.
const derivedKeys = kblib._extend.offline.deriveFromMnemonic('<12_word_seed_phrase_goes_here>');
const transactionObject = {
nonce: <account>,
gasPrice: '0x2FAF080',
gasLimit: '0x1E8480',
data: '<bytecode_goes_here>',
value: '0x0'
}
const signedTransaction = kblib._extend.offline.signTransaction(transactionObject, derivedKeys.privateKey, 'MAINNET');
// Kanban methods - requires setting up a provider to access kanban node - IPC or HTTP provider
// IPC provider
const provider = new Kblib.providers.IpcProvider(<path to geth.ipc file on kanban node>, net);
kblib.setProvider(provider, null, { defaultBlock: 'latest' });
// OR
// HTTP Provider
const provider = new Kblib.providers.HttpProvider('http://localhost:8545', net);
kblib.setProvider(provider, null, { defaultBlock: 'latest' });
// Using the now-connected node to submit a transaction to the network
kblib.kanban.sendRawTransaction(signedTransaction, callbackFunction);
- Kblib
- Kblib.kanban
- Properties
- kanban.getBlock
- kanban.getTransaction
- kanban.getTransactionFromBlock
- kanban.getTransactionReceipt
- kanban.pendingTransactions
- kanban.getTransactionCount
- kanban.getBlockTransactionCount
- kanban.getUncle
- kanban.getUncleCount
- kanban.getBalance
- kanban.sendRawTransaction
- kanban.getStorageAt
- kanban.getCode
- kanban.call
- kanban.estimateGas
- kanban.getWork
- kanban.submitWork
- kanban.getLogs
- Kblib._extend.offline
- Kblib._extend.utils
- utils.padLeft
- utils.padRight
- utils.toHex
- utils.toDecimal
- utils.fromDecimal
- utils.toUtf8
- utils.toAscii
- utils.fromUtf8
- utils.fromAscii
- utils.toWei
- utils.fromWei
- utils.toBigNumber
- utils.toTwosComplement
- utils.isBigNumber
- utils.isStrictAddress
- utils.isAddress
- utils.isChecksumAddress
- utils.toChecksumAddress
- utils.isFunction
- utils.isString
- utils.isObject
- utils.isBoolean
- utils.isArray
- utils.isJson
- Kblib._extend.coders
kblib.sha3(stringToHash)
Will calculate the keccak256 of the input.
- stringToHash - String - The string to be hashed
- String - sha3/keccak256 hashed version of stringToHash
Property | Return-type | Description |
---|---|---|
settings | Object | contains properties set for this instance of the module |
kanban.coinbase | String | the coinbase address to which mining rewards will go |
kanban.mining | Boolean | checks whether the node is mining or not |
kanban.hashrate | Number | number of hashes per second that the node is mining with |
kanban.syncing | syncing object or boolean | if node is syncing, returns syncing object, otherwise false |
kanban.gasPrice | BigNumber | current gas price oracle determined by median of last few blocks |
kanban.accounts | array of String | array of addresses controlled by node |
kanban.blockNumber | Object | object containing "blockNumber" and "blockNumberHex" |
kanban.protocolVersion | String | protocol version of the node in hexadecimal format |
version.network | String | which kanban network the node is a part of |
net.peerCount | Number | Returns number of peers currently connected to the client |
net.listening | Boolean | Returns true if client is listening for network connections. |
kblib.kanban.getBlock(blockHashOrBlockNumber [, returnTransactionObjects])
Returns a block matching the block number or block hash.
- blockHashOrBlockNumber - String|Number - The block number or block hash. Or the string "genesis", "latest" or "pending" as in the default block parameter.
- returnTransactionObjects - Boolean - (optional, default false) If true, the returned block will contain all transactions as objects, if false it will only contains the transaction hashes.
- block object:
- number - Number: The block number. null when its pending block.
- hash 32 Bytes - String: Hash of the block. null when its pending block.
- parentHash 32 Bytes - String: Hash of the parent block.
- nonce 8 Bytes - String: Hash of the generated proof-of-work. null when its pending block.
- sha3Uncles 32 Bytes - String: SHA3 of the uncles data in the block.
- logsBloom 256 Bytes - String: The bloom filter for the logs of the block. null when its pending block.
- transactionsRoot 32 Bytes - String: The root of the transaction trie of the block
- stateRoot 32 Bytes - String: The root of the final state trie of the block.
- receiptsRoot 32 Bytes - String: Transaction receipts are used to store the state after a transaction has been executed and are kept in an index-keyed trie. The hash of its root is placed in the block header as the receipts root.
- miner - String: The address of the beneficiary to whom the mining rewards were given.
- difficulty - String: Integer of the difficulty for this block.
- totalDifficulty - String: Integer of the total difficulty of the chain until this block.
- extraData - String: The “extra data” field of this block.
- size - Number: Integer the size of this block in bytes.
- gasLimit - Number: The maximum gas allowed in this block.
- gasUsed - Number: The total used gas by all transactions in this block.
- timestamp - Number: The unix timestamp for when the block was collated.
- transactions - Array: Array of transaction objects, or 32 Bytes transaction hashes depending on the returnTransactionObjects parameter.
kblib.kanban.getTransaction(transactionHash)
Returns a transaction matching the given transaction hash.
- transactionHash - String - The hash of the transaction to be looked up
- transaction Object:
- hash 32 Bytes - String: Hash of the transaction.
- nonce - Number: The number of transactions made by the sender prior to this one.
- blockHash 32 Bytes - String: Hash of the block where this transaction was in. null when its pending.
- blockNumber - Number: Block number where this transaction was in. null when its pending.
- transactionIndex - Number: Integer of the transactions index position in the block. null when its pending.
- from - String: Address of the sender.
- to - String: Address of the receiver. null when its a contract creation transaction.
- value - String: Value transferred in wei.
- gasPrice - String: The wei per unit of gas provided by the sender in wei.
- gas - Number: Gas provided by the sender.
- input - String: The data sent along with the transaction.
kblib.kanban.getTransactionFromBlock(blockHashOrBlockNumber, indexNumber)
Returns a transaction based on a block hash or number and the transactions index position.
- blockHashOrBlockNumber - String|Number - The hash or block number of the block containing the transaction
- indexNumber - Number - The index of the transaction within the block
- transaction Object:
- hash 32 Bytes - String: Hash of the transaction.
- nonce - Number: The number of transactions made by the sender prior to this one.
- blockHash 32 Bytes - String: Hash of the block where this transaction was in. null when its pending.
- blockNumber - Number: Block number where this transaction was in. null when its pending.
- transactionIndex - Number: Integer of the transactions index position in the block. null when its pending.
- from - String: Address of the sender.
- to - String: Address of the receiver. null when its a contract creation transaction.
- value - String: Value transferred in wei.
- gasPrice - String: The wei per unit of gas provided by the sender in wei.
- gas - Number: Gas provided by the sender.
- input - String: The data sent along with the transaction.
kblib.kanban.getTransactionReceipt(transactionHash)
Returns the receipt of a transaction by transaction hash.
- transactionHash - String - The hash of the transaction to be looked up
- transaction receipt Object | null:
- status - Boolean: TRUE if the transaction was successful, FALSE, if the EVM reverted the transaction.
- blockHash 32 Bytes - String: Hash of the block where this transaction was in.
- blockNumber - Number: Block number where this transaction was in.
- transactionHash 32 Bytes - String: Hash of the transaction.
- transactionIndex- Number: Integer of the transactions index position in the block.
- from - String: Address of the sender.
- to - String: Address of the receiver. null when its a contract creation transaction.
- contractAddress - String: The contract address created, if the transaction was a contract creation, otherwise null.
- cumulativeGasUsed - Number: The total amount of gas used when this transaction was executed in the block.
- gasUsed - Number: The amount of gas used by this specific transaction alone.
- logs - Array: Array of log objects, which this transaction generated.
kblib.kanban.pendingTransactions()
Returns a list of pending transactions.
- none
- Array of transaction objects:
- hash 32 Bytes - String: Hash of the transaction.
- nonce - Number: The number of transactions made by the sender prior to this one.
- blockHash 32 Bytes - String: Hash of the block where this transaction was in. null when its pending.
- blockNumber - Number: Block number where this transaction was in. null when its pending.
- transactionIndex - Number: Integer of the transactions index position in the block. null when its pending.
- from - String: Address of the sender.
- to - String: Address of the receiver. null when its a contract creation transaction.
- value - String: Value transferred in wei.
- gasPrice - String: The wei per unit of gas provided by the sender in wei.
- gas - Number: Gas provided by the sender.
- input - String: The data sent along with the transaction.
kblib.kanban.getTransactionCount(address [, defaultBlock])
Get the numbers of transactions sent from this address.
- address - String - The address that you want to see the transaction count of
- blockNumber - String|Number - (optional, default "latest") The block number in decimal or hex format. Or the string "genesis", "latest" or "pending".
- Number - The number of transactions sent from the address in the given (or latest) block
kblib.kanban.getBlockTransactionCount(blockHashOrBlockNumber)
Returns the number of transaction in a given block.
- blockHashOrBlockNumber - String|Number - The block number or block hash. Or the string "genesis", "latest" or "pending" as in the default block parameter.
- Number - The number of transactions in the given block
kblib.kanban.getUncle(blockHashOrBlockNumber, uncleIndex)
Returns a blocks uncle by a given uncle index position.
- blockHashOrBlockNumber - String|Number - The hash or block number. Or the string "genesis", "latest" or "pending" as in the default block parameter.
- uncleIndex - Number - The index position of the uncle
- block object:
- number - Number: The block number. null when its pending block.
- hash 32 Bytes - String: Hash of the block. null when its pending block.
- parentHash 32 Bytes - String: Hash of the parent block.
- nonce 8 Bytes - String: Hash of the generated proof-of-work. null when its pending block.
- sha3Uncles 32 Bytes - String: SHA3 of the uncles data in the block.
- logsBloom 256 Bytes - String: The bloom filter for the logs of the block. null when its pending block.
- transactionsRoot 32 Bytes - String: The root of the transaction trie of the block
- stateRoot 32 Bytes - String: The root of the final state trie of the block.
- receiptsRoot 32 Bytes - String: Transaction receipts are used to store the state after a transaction has been executed and are kept in an index-keyed trie. The hash of its root is placed in the block header as the receipts root.
- miner - String: The address of the beneficiary to whom the mining rewards were given.
- difficulty - String: Integer of the difficulty for this block.
- totalDifficulty - String: Integer of the total difficulty of the chain until this block.
- extraData - String: The “extra data” field of this block.
- size - Number: Integer the size of this block in bytes.
- gasLimit - Number: The maximum gas allowed in this block.
- gasUsed - Number: The total used gas by all transactions in this block.
- timestamp - Number: The unix timestamp for when the block was collated.
- transactions - Array: Array of transaction objects, or 32 Bytes transaction hashes depending on the returnTransactionObjects parameter.
kblib.kanban.getUncleCount(blockHashOrBlockNumber)
Returns then number of uncles for a given block.
- blockHashOrBlockNumber - String|Number - The hash or block number. Or the string "genesis", "latest" or "pending" as in the default block parameter. If left blank, this method will not default to anything.
- Number : The chosen block's uncle count
kblib.kanban.getBalance(address [, defaultBlock])
Get the balance of an address at a given block.
- address - String - The address to get the balance of
- defaultBlock - Number|String - (optional) - if you pass this parameter it will not use the default block set with kblib.kanban.defaultBlock.
- balance object:
- BTC - String - The Bitcoin balance in hexadecimal format
- ETH - String - The Ether balance in hexadecimal format
- FAB - String - The FABcoin balance in hexadecimal format
kblib.kanban.sendRawTransaction(signedTransactionData)
Sends an already signed transaction, generated for example using kblib.kanban.accounts.signTransaction
- signedTransactionData - String - signed transaction data in hex format
- String - 32 byte hash of the transaction
kblib.kanban.getStorageAt(address, position [, defaultBlock])
Get the storage at a specific position of an address.
- address - String - The address to get the storage from.
- position - Number - The index position of the storage.
- defaultBlock - String|Number - (optional, default "latest") The block number in decimal or hex format. Or the string "genesis", "latest" or "pending".
- String - The value in storage at the given position, as a hex string
kblib.kanban.getCode(address [, defaultBlock])
Get the code at a specific address.
- address - String - The address of the smart contract
- defaultBlock - String|Number - (optional, default "latest") The block number in decimal or hex format. Or the string "genesis", "latest" or "pending".
- String - The code at the given address, as a hex string
kblib.kanban.call(callObject [, defaultBlock])
Executes a message call transaction, which is directly executed in the VM of the node, but never mined into the blockchain.
- callObject - transaction Object - The transaction object to send:
- from - String|Number: (optional) The address for the sending account. Uses the kblib.kanban.defaultAccount property, if not specified. Or an address or index of a local wallet in kblib.kanban.accounts.wallet.
- to - String: (optional) The destination address of the message, left undefined for a contract-creation transaction.
- coin - String (optional) The type of coin you wish to send. Currently supports ("FAB", "BTC", "ETH"). Default "FAB".
- value - Number|String|BN|BigNumber: (optional) The value transferred for the transaction in wei, also the endowment if it’s a contract-creation transaction.
- gas - Number: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).
- gasPrice - Number|String|BN|BigNumber: (optional) The price of gas for this transaction in wei, defaults to kblib.kanban.gasPrice.
- data - String: (optional) Either a ABI byte string containing the data of the function call on a contract, or in the case of a contract-creation transaction the initialization code.
- nonce - Number: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
- defaultBlock - String|Number - (optional, default "latest") The block number in decimal or hex format. Or the string "genesis", "latest" or "pending".
- String - The returned data of the call, e.g. a smart contract functions return value.
kblib.kanban.estimateGas(callObject)
Executes a message call or transaction and returns the amount of the gas used.
- callObject - transaction Object - The transaction object to send:
- from - String|Number: (optional) The address for the sending account. Uses the kblib.kanban.defaultAccount property, if not specified. Or an address or index of a local wallet in kblib.kanban.accounts.wallet.
- to - String: (optional) The destination address of the message, left undefined for a contract-creation transaction.
- coin - String (optional) The type of coin you wish to send. Currently supports ("FAB", "BTC", "ETH"). Default "FAB".
- value - Number|String|BN|BigNumber: (optional) The value transferred for the transaction in wei, also the endowment if it’s a contract-creation transaction.
- gas - Number: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).
- gasPrice - Number|String|BN|BigNumber: (optional) The price of gas for this transaction in wei, defaults to kblib.kanban.gasPrice.
- data - String: (optional) Either a ABI byte string containing the data of the function call on a contract, or in the case of a contract-creation transaction the initialization code.
- nonce - Number: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
- Number - The amount of gas used in the simulated execution of the call
kblib.kanban.getWork()
Executes a message call or transaction and returns the amount of the gas used.
- none
- Array (3 elements) :
- String (32 Bytes) at index 0: current block header pow-hash
- String (32 Bytes) at index 1: the seed hash used for the DAG.
- String (32 Bytes) at index 2: the boundary condition (“target”), 2^256 / difficulty.
kblib.kanban.submitWork(callObject)
Executes a message call or transaction and returns the amount of the gas used.
- nonce - String (8 Bytes) - The nonce found (64 bits)
- powHash - String (32 Bytes) - The header’s pow-hash (256 bits)
- digest - String (32 Bytes) - The mix digest (256 bits)
- Boolean - Returns true if the provided solution is valid, otherwise false.
kblib.kanban.getLogs(options)
Returns an array of all logs matching a given filter object.
- filter object::
- fromBlock - Number|String - (optional, default 'latest') integer block number or 'latest', 'pending', or 'earliest'
- toBlock - Number|String - (optional, default 'latest') integer block number or 'latest', 'pending', or 'earliest'
- address - String|Array - (optional) Contract address or a list of addresses from which logs should originate.
- topics - Array of String- (optional) array of 32 Byte topic strings. Topics are order-dependent. Each topic can also be an array of String with "or" options
- blockhash - String (32 Byte hex) - (optional) Restricts the logs returned to the single block with the 32-byte hash blochHash. using blockHash is equivalent to fromBlock = toBlock = the block number with hash blockHash. In order to use blockHash, fromBlock and toBlock must not be specified.
- Array of log objects:
- for filters created with kanban_newBlockFilter, the returned are block hashes (32 Byte hex string)
- for filters created with kanban_newPendingTransactionFilter, the returned are transaction hashes (32 Byte hex string)
- for filters created with kanban_newFilter logs are objects with the following parameters:
- type - String - 'pending' when the log is pending, 'mined' if log is already mined
- logIndex - Number - integer of the transactions index position log was created from. null when its pending log.
- transactionHash - String - (32 Byte hex string) - hash of the transactions this log was created from. null when its pending log.
- blockHash - String (32 Byte hex string ) - hash of the block this log was in. null when its pending. null when its pending log.
- blockNumber - Number - the block number this log was in. null when its pending. null when its pending log.
- address - String (20 Byte hex string) - address from which this log originated
- data - String - contains one or more 32 Byte non-indexed arguments of the log.
- topics - Array of String - Array of 0 to 4 32 Byte strings of indexed log arguments.
kblib._extend.offline.deriveFromMnemonic(mnemonic [, network])
Takes a mnemonic string and derives a set of keys and addresses.
- mnemonic - String - 12+ word space-separated mnemonic string used to seed the private key and other data.
- network - String - (optional, default 'MAINNET') Can be 'MAINNET' or 'TESTNET'.
- Object:
- privateKey - hex string - Private key generated from the mnemonic, in hexadecimal format.
- privateKeyWIF - Private key generated from the mnemonic, in Wallet Import Format (WIF).
- publicKey - Compressed public key derived from this private key.
- address - The ethereum-style kanban address in hex, derived from this public key.
kblib._extend.offline.signTransaction(transactionObject, privateKey [, network])
RECOMMENDED
Takes a supplied transaction object and returns a signed transaction using the supplied private key. This signing is done locally, and is more secure than kanban.signTransaction.
- transactionObject: - String - 12+ word space-separated mnemonic string used to seed the private key and other data.
- nonce - number or hex string - Desired nonce for the transaction. Typically this will be equal to the value returne by kanban.getTransactionCount, but can be higher. Transactions of an account are mined in order of increasing nonce..
- gasPrice - number or hex string - Desired gas price for the transaction.
- gasLimit - number or hex string - Desired gas limit for the transaction. If this is too low the transaction may fail, depending on the contract.
- to - hex string - (semi-optional, default - none) Recipient Address. Omit for contract creation. Otherwise required.
- data - hex string - (semi-optional, default '0x0') Omit if "send" transaction. Otherwise recommended to include.
- value - hex string - (semi-optional, default '0x0') Required if "send" transaction. Otherwise only include if calling a payable function in contract, or it can be used by the constructor if deploying smart contract.
- privateKey - String - Private key in hexadecimal format. Can be generated via offline.deriveFromMnemonic.
- network - String - (optional, default 'MAINNET') Can be 'MAINNET' or 'TESTNET'.
- String - The signed transaction, a hex string. Can be submitted via kanban.sendRawTransaction.
kblib._extend.utils.padLeft(string, characterAmount [, sign])
Adds a padding on the left of a string, Useful for adding paddings to HEX strings.
- string - String - The string to add padding on the left
- characterAmount - Number - The number of characters the total string should have
- sign - String - (optional, default '0') The character sign to use
- String - The padded string
kblib._extend.utils.padRight(string, characterAmount [, sign])
Adds a padding on the right of a string, Useful for adding paddings to HEX strings.
- string - String - The string to add padding on the left
- characterAmount - Number - The number of characters the total string should have
- sign - String - (optional, default '0') The character sign to use
- String - The padded string
kblib._extend.utils.toHex(mixed)
Will auto convert any given value to HEX. Number strings will interpreted as numbers. Text strings will be interpreted as UTF-8 strings.
- mixed - String|Number|BN|BigNumber - The input to convert to hex.
- String - The resulting hex string
kblib._extend.utils.toDecimal(hex)
Returns the number representation of a given HEX value. This is not useful for big numbers
- hexString - String|HEX - A string to convert to decimal representation
- Number - The decimal representation of the hex string
kblib._extend.utils.fromDecimal(number)
Returns the HEX representation of a given number value.
- number - String|Number|BN|BigNumber - A number as a string or number
- String - A hex string representation of the number
kblib._extend.utils.toUtf8(hex)
Returns the UTF-8 string representation of a given HEX value.
- hex - String - A hex string to convert to a UTF-8 string
- String - The UTF-8 string
kblib._extend.utils.toAscii(hex)
Returns the ASCII string representation of a given HEX value.
- hex - String - A hex string to convert to an ASCII string
- String - The ASCII string
kblib._extend.utils.fromUtf8(string)
Returns the HEX representation of a given UTF-8 string.
- string - String - A UTF-8 string to convert to as hex string.
- String - The hex string
kblib._extend.utils.fromAscii(string [, length])
Returns the HEX representation of a given ASCII string. If you would like to transform an ASCII string into a valid bytes4, bytes8 etc. value then please pass the correct length as the second parameter
- string - String - The ASCII string to convert to a hex string
- length - Number - (optional, default 32) The length of the returned hex string.
- String - The hex string
kblib._extend.utils.toWei(number [, unit])
Converts any ether value into wei // TO DO: change this?
- number - String|BN - The value in the unit provided
- unit - String - (optional, default 'ether') The ether value to convert from. Possible values omitted.
- String | BN - If a string is given, it returns a number string, otherwise returns a BN.js instance
kblib._extend.utils.fromWei(number [, unit])
Converts any wei value into an ether value.
- number - String|BN - The value in wei
- unit - String - (optional, default 'ether') The ether value to convert to. Possible values omitted.
- String - It always returns a string number.
kblib._extend.utils.toBigNumber(number)
Convert a number from various forms to to a BigNumber
- number - String|Number|Hex - Parameter Description
- BigNumber - BigNumber format of the number
kblib._extend.utils.toTwosComplement()
Converts a negative number into a two’s complement.
- number - Number|String|BigNumber - The number to convert.
- String - The converted hex string
kblib._extend.utils.isBigNumber(bigNumber)
Description goes here
- bigNumber - BigNumber Object - A BigNumber.js instance
- Boolean - true if bigNumber is a an instance of BigNumber
kblib._extend.utils.isStrictAddress(address [, chainId])
Checks if a given string is a valid Kanban address, including the requirement that begin wit '0x'. It will also check the checksum, if the address has both upper and lowercase letters.
- address - String - An address string
- chainId - Number - Chain id where checksummed address should be valid, defaults to null.
- Boolean - true if the address is valid and prefixed with '0x'
kblib._extend.utils.isAddress(address [, chainId])
Checks if a given string is a valid Kanban address. It will also check the checksum, if the address has both upper and lowercase letters.
- address - String - An address string
- chainId - Number - Chain id where checksummed address should be valid, defaults to null.
- Boolean - true if the address is valid
kblib._extend.utils.isChecksumAddress(address)
Checks if a given string is a valid Kanban address and ikf the address has both upper and lowercase letters.
- address - String - An address string
- Boolean - true if the address is valid and contains mixed case
kblib._extend.utils.toChecksumAddress(address [, chainId])
Will convert an upper or lowercase Kanban address to a checksum address.
- address - String - An address string
- chainId - Number - Chain id where checksummed address should be valid, defaults to null.
- String - The checksum address
kblib._extend.utils.isFunction(function)
Checks if the passed parameter is a function
- function - Object|other - The object you wish to verify is a function
- Boolean - true if the passed parameter is a function
kblib._extend.utils.isString(string)
Checks if the passed parameter is a string
- string - String|other - some passed parameter
- Boolean - true if the passed parameter is a String
kblib._extend.utils.isObject(object)
Checks if the passed parameter is an object
- object - Object|other - some passed parameter
- Boolean - true if the passed parameter is an Object
kblib._extend.utils.isBoolean(boolean)
Checks if the passed parameter is a boolean
- boolean - Boolean|other - some passed parameter
- Boolean - true if the passed parameter is a Boolean
kblib._extend.utils.isArray(array)
Checks if the passed parameter is an array
- array - Array|other - some passed parameter
- Boolean - true if the passed parameter is an Array
kblib._extend.utils.isString(string)
Checks if the passed parameter is a valid JSON string
- string - String|other - some passed parameter
- Boolean - true if the passed parameter is valid JSON string
kblib._extend.coders.encodeParam(type, param)
Encodes one parameter for use in a smart contract ABI
- type - String - The type of the parameter to be encoded for the ABI
- param - String - The parameter to be encoded
- String - The ABI-encoded parameter
kblib._extend.coders.encodeParams(types, params)
Encodes an array of parameters for use in a smart contract ABI
- types - Array of String - The types of the parameters to be encoded for the ABI
- params - Array of String - The parameters to be encoded, in order
- String - The ABI-encoded parameters
kblib._extend.coders.decodeParam(type, bytes)
Decodes an ABI encoded parameter to its JavaScript type.
- type - String - The JavaScript type of the parameter
- bytes - String - The encoded parameter to be decoded
- various types - The ABI-decoded parameter. Type depends on the one supplied
kblib._extend.coders.decodeParams(types, bytes)
Decodes ABI encoded parameters to their JavaScript types.
- types - Array of String - The JavaScript type of the parameters
- bytes - String - A string of the encoded parameters to be decoded
- Array of various types - The ABI-decoded parameters. Types depend on the ones supplied.
kblib._extend.coders.encodeFunctionSignature(functionName, types)
Encodes the function name to its ABI signature, which are the first 4 bytes of the sha3 hash of the function name including types.
- functionName - String - the name of the function
- types - Array of String | String - The solidity types of the parameters in the function signature
- String - The ABI-encoded function signature (pre-pended with '0x')
kblib._extend.coders.encodeFunctionCall(functionName, types, params)
Encodes the function call for use with a contract ABI. which are the first 4 bytes of the sha3 hash of the function name including parameters.
- functionName - String - the name of the Function
- types - Array of String | String - The solidity types of the parameters in the function signature
- params - Array of String | String - The parameters to be used in the function call
- String - The ABI-encoded function call (pre-pended with '0x')