Skip to content

Latest commit

 

History

History
109 lines (86 loc) · 4.91 KB

index.md

File metadata and controls

109 lines (86 loc) · 4.91 KB

Functions

createTransaction(expireInSeconds, callback)

Consult the blockchain and gather information for use in a new signed transaction. For Transaction as Proof of Stake (TaPOS), 32 bits of a recent block Id is included. Because all transactions use TaPOS, this solves the nothing at stake attack.

This is usually called for every transaction or maybe cached per block. Although longer caching is possible, a longer cache time increases the risk of a transaction replay attack.

processArgs(args, defParams, methodName, [optionsFormatter(extraParam)])processedArgs

Convert args array or object into a normalized value object. Suppoorts extra options and(or) callback parameters.

Per the Promise API feature promisifyAll (see also sb-promisify), the callback (if provided) must always be last.

Typedefs

headers : object
processedArgs : object

Normalized object containing arguments, and a chained promise and a callback.

createTransaction(expireInSeconds, callback)

Consult the blockchain and gather information for use in a new signed transaction. For Transaction as Proof of Stake (TaPOS), 32 bits of a recent block Id is included. Because all transactions use TaPOS, this solves the nothing at stake attack.

This is usually called for every transaction or maybe cached per block. Although longer caching is possible, a longer cache time increases the risk of a transaction replay attack.

Kind: global function
See: {headers}

Param Type Default Description
expireInSeconds number 60 How many seconds until expiration
callback function headers

Example

eos.createTransaction(60, (error, headers) => {})

processArgs(args, defParams, methodName, [optionsFormatter(extraParam)]) ⇒ processedArgs

Convert args array or object into a normalized value object. Suppoorts extra options and(or) callback parameters.

Per the Promise API feature promisifyAll (see also sb-promisify), the callback (if provided) must always be last.

Kind: global function
Returns: processedArgs - processedArgs
Throws:

  • TypeError - when parameter count is not exact (after adjusting for options and callback)
Param Type Default Description
args Array | object User-provided parameter object or array of parameters
defParams Array Names for the parameters.
methodName string "method" for error reporting
[optionsFormatter(extraParam)] function optional callback used if an extra optional (non-callback) parameter is provided.

Example

api.processArgs(args, ['account'], 'contract', optionsFormatter)

headers : object

Kind: global typedef
Properties

Name Type Description
ref_block_num number Last irreversible block number. The bit-wise AND operation is used to keep this value with the size of a Uint16 size (a block num in the last 2^16 blocks). Example: get_info.last_irreversible_block_num & 0xFFFF
ref_block_prefix number get_block.ref_block_prefix .. This is a 32 bit number identifier (identify the same block referenced in ref_block_num).
expiration string This is based on the head block time from the blockchain. Be careful to suffix a Z if required (as with Firefox and JavaScript) to ensure this date string is interpreted as Zulu time. Example: new Date(new Date(info.head_block_time + 'Z').getTime() + expireInSeconds * 1000).toISOString().split('.')[0]

processedArgs : object

Normalized object containing arguments, and a chained promise and a callback.

Kind: global typedef
Properties

Name Type Description
params object normalized args only, parameters by name, no extra options or callback.
options object non-null or non-undefined return value from invocation of optionsFormatter(optionsParam).
callback function chained to optional callback provided in args. Resolves or rejects returnPromise.
returnPromise Promise promise is returned when no callback is provided in args[args.length - 1]. Undefined when a callback is provided.