@burstjs/contracts
Generic HTTP client that is used as a network provider for @burst/core.
Installation
@burstjs/contracts
can be used with NodeJS or Web. Two formats are available
Using with NodeJS and/or modern web frameworks
Install using npm:
npm install @burstjs/contracts
or using yarn:
yarn add @burstjs/contracts
Example
Using in classic <script>
Each package is available as bundled standalone library using IIFE.
This way burstJS can be used also within <script>
-Tags.
This might be useful for Wordpress and/or other PHP applications.
Just import the package using the HTML <script>
tag.
<script src='https://cdn.jsdelivr.net/npm/@burstjs/http/dist/burstjs.http.min.js'></script>
Example
See more here:
@burstjs/contracts Online Documentation
API Reference
Modules
- contracts
Classes
- ContractDataView
Helper class for contracts
A contract owns additional data, which is split in 8 byte blocks.
The content is encoded in hexadecimal representation and big endianness.
This class facilitates access to these data
contracts
contracts~CodePageSize
Size of Code Pages in bytes
Kind: inner constant of contracts
contracts~calculateMinimumCreationFee(hexCode) ⇒
Calculates the minimum creation fee of the contract
Kind: inner method of contracts
Returns:
The minimum fee expressed in Planck
Param | Description |
---|
hexCode | The contracts code in hex form |
contracts~countCodePages(hexCode) ⇒
Counts the code pages for given machine code
Kind: inner method of contracts
Returns:
The number of code pages for the passed code
Param | Description |
---|
hexCode | The contracts code in hex form |
contracts~numericToHex()
Copyright (c) 2019 Burst Apps Team
Credits to AJ ONeal for the two-complements stuff
https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/
Kind: inner method of contracts
contracts~generateMethodCall(args) ⇒
Generates a method call message of a contracts public method. The message can be sent using for example
[[MessageApi.sendMessage]] with messageIsText = false
or [[ContractApi.callMethod]]]
Kind: inner method of contracts
Returns:
A hex string that can be used as contracts transaction message
Param | Description |
---|
args | The argument object |
contracts~getContractDatablock(contract, position, length) ⇒
Extracts a variables value as hexadecimal string from a contract's machine data
This is a generic function to extract arbitrary data from a contract. It's recommended to use the [[ContractDataView]] class instead
Kind: inner method of contracts
Returns:
The value as hexadecimal string (already considering endianness)
Param | Default | Description |
---|
contract | | The contract |
position | | The variables position |
length | 16 | The length of data to be extracted |
contracts
contracts~CodePageSize
Size of Code Pages in bytes
Kind: inner constant of contracts
contracts~calculateMinimumCreationFee(hexCode) ⇒
Calculates the minimum creation fee of the contract
Kind: inner method of contracts
Returns:
The minimum fee expressed in Planck
Param | Description |
---|
hexCode | The contracts code in hex form |
contracts~countCodePages(hexCode) ⇒
Counts the code pages for given machine code
Kind: inner method of contracts
Returns:
The number of code pages for the passed code
Param | Description |
---|
hexCode | The contracts code in hex form |
contracts~numericToHex()
Copyright (c) 2019 Burst Apps Team
Credits to AJ ONeal for the two-complements stuff
https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/
Kind: inner method of contracts
contracts~generateMethodCall(args) ⇒
Generates a method call message of a contracts public method. The message can be sent using for example
[[MessageApi.sendMessage]] with messageIsText = false
or [[ContractApi.callMethod]]]
Kind: inner method of contracts
Returns:
A hex string that can be used as contracts transaction message
Param | Description |
---|
args | The argument object |
contracts~getContractDatablock(contract, position, length) ⇒
Extracts a variables value as hexadecimal string from a contract's machine data
This is a generic function to extract arbitrary data from a contract. It's recommended to use the [[ContractDataView]] class instead
Kind: inner method of contracts
Returns:
The value as hexadecimal string (already considering endianness)
Param | Default | Description |
---|
contract | | The contract |
position | | The variables position |
length | 16 | The length of data to be extracted |
contracts
contracts~CodePageSize
Size of Code Pages in bytes
Kind: inner constant of contracts
contracts~calculateMinimumCreationFee(hexCode) ⇒
Calculates the minimum creation fee of the contract
Kind: inner method of contracts
Returns:
The minimum fee expressed in Planck
Param | Description |
---|
hexCode | The contracts code in hex form |
contracts~countCodePages(hexCode) ⇒
Counts the code pages for given machine code
Kind: inner method of contracts
Returns:
The number of code pages for the passed code
Param | Description |
---|
hexCode | The contracts code in hex form |
contracts~numericToHex()
Copyright (c) 2019 Burst Apps Team
Credits to AJ ONeal for the two-complements stuff
https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/
Kind: inner method of contracts
contracts~generateMethodCall(args) ⇒
Generates a method call message of a contracts public method. The message can be sent using for example
[[MessageApi.sendMessage]] with messageIsText = false
or [[ContractApi.callMethod]]]
Kind: inner method of contracts
Returns:
A hex string that can be used as contracts transaction message
Param | Description |
---|
args | The argument object |
contracts~getContractDatablock(contract, position, length) ⇒
Extracts a variables value as hexadecimal string from a contract's machine data
This is a generic function to extract arbitrary data from a contract. It's recommended to use the [[ContractDataView]] class instead
Kind: inner method of contracts
Returns:
The value as hexadecimal string (already considering endianness)
Param | Default | Description |
---|
contract | | The contract |
position | | The variables position |
length | 16 | The length of data to be extracted |
contracts
contracts~CodePageSize
Size of Code Pages in bytes
Kind: inner constant of contracts
contracts~calculateMinimumCreationFee(hexCode) ⇒
Calculates the minimum creation fee of the contract
Kind: inner method of contracts
Returns:
The minimum fee expressed in Planck
Param | Description |
---|
hexCode | The contracts code in hex form |
contracts~countCodePages(hexCode) ⇒
Counts the code pages for given machine code
Kind: inner method of contracts
Returns:
The number of code pages for the passed code
Param | Description |
---|
hexCode | The contracts code in hex form |
contracts~numericToHex()
Copyright (c) 2019 Burst Apps Team
Credits to AJ ONeal for the two-complements stuff
https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/
Kind: inner method of contracts
contracts~generateMethodCall(args) ⇒
Generates a method call message of a contracts public method. The message can be sent using for example
[[MessageApi.sendMessage]] with messageIsText = false
or [[ContractApi.callMethod]]]
Kind: inner method of contracts
Returns:
A hex string that can be used as contracts transaction message
Param | Description |
---|
args | The argument object |
contracts~getContractDatablock(contract, position, length) ⇒
Extracts a variables value as hexadecimal string from a contract's machine data
This is a generic function to extract arbitrary data from a contract. It's recommended to use the [[ContractDataView]] class instead
Kind: inner method of contracts
Returns:
The value as hexadecimal string (already considering endianness)
Param | Default | Description |
---|
contract | | The contract |
position | | The variables position |
length | 16 | The length of data to be extracted |
contracts
contracts~CodePageSize
Size of Code Pages in bytes
Kind: inner constant of contracts
contracts~calculateMinimumCreationFee(hexCode) ⇒
Calculates the minimum creation fee of the contract
Kind: inner method of contracts
Returns:
The minimum fee expressed in Planck
Param | Description |
---|
hexCode | The contracts code in hex form |
contracts~countCodePages(hexCode) ⇒
Counts the code pages for given machine code
Kind: inner method of contracts
Returns:
The number of code pages for the passed code
Param | Description |
---|
hexCode | The contracts code in hex form |
contracts~numericToHex()
Copyright (c) 2019 Burst Apps Team
Credits to AJ ONeal for the two-complements stuff
https://coolaj86.com/articles/convert-decimal-to-hex-with-js-bigints/
Kind: inner method of contracts
contracts~generateMethodCall(args) ⇒
Generates a method call message of a contracts public method. The message can be sent using for example
[[MessageApi.sendMessage]] with messageIsText = false
or [[ContractApi.callMethod]]]
Kind: inner method of contracts
Returns:
A hex string that can be used as contracts transaction message
Param | Description |
---|
args | The argument object |
contracts~getContractDatablock(contract, position, length) ⇒
Extracts a variables value as hexadecimal string from a contract's machine data
This is a generic function to extract arbitrary data from a contract. It's recommended to use the [[ContractDataView]] class instead
Kind: inner method of contracts
Returns:
The value as hexadecimal string (already considering endianness)
Param | Default | Description |
---|
contract | | The contract |
position | | The variables position |
length | 16 | The length of data to be extracted |
ContractDataView
Helper class for contracts
A contract owns additional data, which is split in 8 byte blocks.
The content is encoded in hexadecimal representation and big endianness.
This class facilitates access to these data
Kind: global class
new ContractDataView()
The length of a contracts variable (considering Hex notation)
contractDataView.getContract() ⇒
Kind: instance method of ContractDataView
Returns:
Get the contract
contractDataView.countCodePages() ⇒
Kind: instance method of ContractDataView
Returns:
The number of code pages
contractDataView.getVariableAsString(index) ⇒
Get a variable as string
Kind: instance method of ContractDataView
Returns:
The data as string (Utf-8)
Param | Description |
---|
index | The index of variable (starting at 0) |
contractDataView.getDataBlocksAsString(index, count) ⇒
Get multiple data blocks as string
Kind: instance method of ContractDataView
Returns:
The data as string (Utf-8)
Param | Description |
---|
index | The index of variable (starting at 0) |
count | Number of blocks |
contractDataView.getVariableAsDecimal(index) ⇒
Get a variable as decimal (string)
Kind: instance method of ContractDataView
Returns:
The data as a decimal string sequence
Param | Description |
---|
index | The index of variable (starting at 0) |
contractDataView.getVariable(index) ⇒
Get a variable at given position/index
Kind: instance method of ContractDataView
Returns:
The data as hexadecimal string (in little endianness)
Param | Description |
---|
index | The index of variable (starting at 0) |
contractDataView.getHexDataAt(index, length) ⇒
Get a hexadecimal data block of arbitrary length at given position/index
Kind: instance method of ContractDataView
Returns:
The data as hexadecimal string (in little endianness)
Param | Description |
---|
index | The index of variable (starting at 0) |
length | The length of the data block (must be a multiple of 2) |