Module debot
Last updated
Last updated
Module for working with debot.
– Creates and instance of DeBot.
– Starts the DeBot.
– Fetches DeBot metadata from blockchain.
– Executes debot action.
– Sends message to Debot.
– Destroys debot handle.
– Handle of registered in SDK debot
– Describes a debot action in a Debot Context.
– Describes DeBot metadata.
– DeBot wants to create new transaction in blockchain.
Downloads debot smart contract (code and data) from blockchain and creates an instance of Debot Engine for it.
It does not switch debot to context 0. Browser Callbacks are not called.
NOTE: Sync version is available only for lib-node
binding.
address
: string – Debot smart contract address
debot_abi
: string – Debot abi as json string.
Downloads debot smart contract from blockchain and switches it to context zero.
This function must be used by Debot Browser to start a dialog with debot. While the function is executing, several Browser Callbacks can be called, since the debot tries to display all actions from the context 0 to the user.
When the debot starts SDK registers BrowserCallbacks
AppObject. Therefore when debote.remove
is called the debot is being deleted and the callback is called with finish
=true
which indicates that it will never be used again.
NOTE: Sync version is available only for lib-node
binding.
Downloads DeBot from blockchain and creates and fetches its metadata.
NOTE: Sync version is available only for lib-node
binding.
address
: string – Debot smart contract address.
Calls debot engine referenced by debot handle to execute input action. Calls Debot Browser Callbacks if needed.
Chain of actions can be executed if input action generates a list of subactions.
NOTE: Sync version is available only for lib-node
binding.
Used by Debot Browser to send response on Dinterface call or from other Debots.
NOTE: Sync version is available only for lib-node
binding.
message
: string – BOC of internal message to debot encoded in base64 format.
Removes handle from Client Context and drops debot engine referenced by that handle.
NOTE: Sync version is available only for lib-node
binding.
One of the following value:
DebotStartFailed = 801
DebotFetchFailed = 802
DebotExecutionFailed = 803
DebotInvalidHandle = 804
DebotInvalidJsonParams = 805
DebotInvalidFunctionId = 806
DebotInvalidAbi = 807
DebotGetMethodFailed = 808
DebotInvalidMsg = 809
DebotExternalCallFailed = 810
DebotBrowserCallbackFailed = 811
DebotOperationRejected = 812
DebotNoCode = 813
description
: string – A short action description.
Should be used by Debot Browser as name of menu item.
name
: string – Depends on action type.
Can be a debot function name or a print string (for Print Action).
action_type
: number – Action type.
to
: number – ID of debot context to switch after action execution.
attributes
: string – Action attributes.
In the form of "param=value,flag". attribute example: instant, args, fargs, sign.
misc
: string – Some internal action data.
Used by debot only.
name
?: string – DeBot short name.
version
?: string – DeBot semantic version.
publisher
?: string – The name of DeBot deployer.
caption
?: string – Short info about DeBot.
author
?: string – The name of DeBot developer.
support
?: string – Acki Nacki address of author for questions and donations.
hello
?: string – String with the first messsage from DeBot.
language
?: string – String with DeBot interface language (ISO-639).
dabi
?: string – String with DeBot ABI.
icon
?: string – DeBot icon.
interfaces
: string[] – Vector with IDs of DInterfaces used by DeBot.
dabiVersion
: string – ABI version ("x.y") supported by DeBot
DeBot wants to create new transaction in blockchain.
msg
: string – External inbound message BOC.
dst
: string – Target smart contract address.
fee
: bigint – Transaction total fee.
setcode
: boolean – Indicates if target smart contract updates its code.
signkey
: string – Public key from keypair that was used to sign external message.
signing_box_handle
: number – Signing box handle used to sign external message.
Depends on value of the type
field.
When type is 'Transaction'
DeBot wants to create new transaction in blockchain.
msg
: string – External inbound message BOC.
dst
: string – Target smart contract address.
fee
: bigint – Transaction total fee.
setcode
: boolean – Indicates if target smart contract updates its code.
signkey
: string – Public key from keypair that was used to sign external message.
signing_box_handle
: number – Signing box handle used to sign external message.
Variant constructors:
amount
: bigint – Amount of nanotokens that will be sent to dst
address.
dst
: string – Destination address of recipient of funds.
address
: string – Debot smart contract address
debot_abi
: string – Debot abi as json string.
Print message to user.
msg
: string – A string that must be printed to user.
Switch debot to another context (menu).
context_id
: number – Debot context ID to which debot is switched.
Notify browser that all context actions are shown.
Show action to the user. Called after switch
for each action in context.
Request user input.
prompt
: string – A prompt string that must be printed to user before input request.
Get signing box to sign data.
Signing box returned is owned and disposed by debot engine
Execute action of another debot.
debot_addr
: string – Address of debot in blockchain.
Used by Debot to call DInterface implemented by Debot Browser.
message
: string – Internal message to DInterface address.
Message body contains interface function and parameters.
Requests permission from DeBot Browser to execute DeBot operation.
Called by debot engine to communicate with debot browser.
Depends on value of the type
field.
When type is 'Log'
Print message to user.
msg
: string – A string that must be printed to user.
When type is 'Switch'
Switch debot to another context (menu).
context_id
: number – Debot context ID to which debot is switched.
When type is 'SwitchCompleted'
Notify browser that all context actions are shown.
When type is 'ShowAction'
Show action to the user. Called after switch
for each action in context.
When type is 'Input'
Request user input.
prompt
: string – A prompt string that must be printed to user before input request.
When type is 'GetSigningBox'
Get signing box to sign data.
Signing box returned is owned and disposed by debot engine
When type is 'InvokeDebot'
Execute action of another debot.
debot_addr
: string – Address of debot in blockchain.
When type is 'Send'
Used by Debot to call DInterface implemented by Debot Browser.
message
: string – Internal message to DInterface address.
Message body contains interface function and parameters.
When type is 'Approve'
Requests permission from DeBot Browser to execute DeBot operation.
Variant constructors:
Result of user input.
value
: string – String entered by user.
Result of getting signing box.
signing_box
: SigningBoxHandle – Signing box for signing data requested by debot engine.
Signing box is owned and disposed by debot engine
Result of debot invoking.
Result of approve
callback.
approved
: boolean – Indicates whether the DeBot is allowed to perform the specified operation.
Depends on value of the type
field.
When type is 'Input'
Result of user input.
value
: string – String entered by user.
When type is 'GetSigningBox'
Result of getting signing box.
signing_box
: SigningBoxHandle – Signing box for signing data requested by debot engine.
Signing box is owned and disposed by debot engine
When type is 'InvokeDebot'
Result of debot invoking.
When type is 'Approve'
Result of approve
callback.
approved
: boolean – Indicates whether the DeBot is allowed to perform the specified operation.
Variant constructors:
address
: string – Debot smart contract address.
message
: string – BOC of internal message to debot encoded in base64 format.
Called by debot engine to communicate with debot browser.
Print message to user.
NOTE: Sync version is available only for lib-node
binding.
msg
: string – A string that must be printed to user.
Switch debot to another context (menu).
NOTE: Sync version is available only for lib-node
binding.
context_id
: number – Debot context ID to which debot is switched.
Notify browser that all context actions are shown.
NOTE: Sync version is available only for lib-node
binding.
Show action to the user. Called after switch
for each action in context.
NOTE: Sync version is available only for lib-node
binding.
Request user input.
NOTE: Sync version is available only for lib-node
binding.
prompt
: string – A prompt string that must be printed to user before input request.
value
: string – String entered by user.
Get signing box to sign data.
Signing box returned is owned and disposed by debot engine
NOTE: Sync version is available only for lib-node
binding.
signing_box
: SigningBoxHandle – Signing box for signing data requested by debot engine.
Signing box is owned and disposed by debot engine
Execute action of another debot.
NOTE: Sync version is available only for lib-node
binding.
debot_addr
: string – Address of debot in blockchain.
Used by Debot to call DInterface implemented by Debot Browser.
NOTE: Sync version is available only for lib-node
binding.
message
: string – Internal message to DInterface address.
Message body contains interface function and parameters.
Requests permission from DeBot Browser to execute DeBot operation.
NOTE: Sync version is available only for lib-node
binding.
approved
: boolean – Indicates whether the DeBot is allowed to perform the specified operation.
– Describes the operation that the DeBot wants to perform.
– Describes how much funds will be debited from the target contract balance as a result of the transaction.
– Parameters to init DeBot.
– Structure for storing debot handle returned from init
function.
– Print message to user.
– Switch debot to another context (menu).
– Notify browser that all context actions are shown.
– Show action to the user. Called after switch
for each action in context.
– Request user input.
– Get signing box to sign data.
– Execute action of another debot.
– Used by Debot to call DInterface implemented by Debot Browser.
– Requests permission from DeBot Browser to execute DeBot operation.
– Debot Browser callbacks
– Result of user input.
– Result of getting signing box.
– Result of debot invoking.
– Result of approve
callback.
– Returning values from Debot Browser callbacks.
– Parameters to start DeBot. DeBot must be already initialized with init() function.
– Parameters to fetch DeBot metadata.
–
– Parameters for executing debot action.
– Parameters of send
function.
–
– Debot Browser callbacks
Creates and instance of DeBot.
obj
: – Debot Browser callbacks
debot_handle
: – Debot handle which references an instance of debot engine.
info
: – Debot metadata.
Starts the DeBot.
debot_handle
: – Debot handle which references an instance of debot engine.
Fetches DeBot metadata from blockchain.
info
: – Debot metadata.
Executes debot action.
debot_handle
: – Debot handle which references an instance of debot engine.
action
: – Debot Action that must be executed.
Sends message to Debot.
debot_handle
: – Debot handle which references an instance of debot engine.
Destroys debot handle.
debot_handle
: – Debot handle which references an instance of debot engine.
Handle of registered in SDK debot
Describes a debot action in a Debot Context.
Describes DeBot metadata.
out
: [] – List of spendings as a result of transaction.
Describes the operation that the DeBot wants to perform.
out
: [] – List of spendings as a result of transaction.
Describes how much funds will be debited from the target contract balance as a result of the transaction.
Parameters to init DeBot.
Structure for storing debot handle returned from init
function.
debot_handle
: – Debot handle which references an instance of debot engine.
info
: – Debot metadata.
action
: – Debot action that must be shown to user as menu item. At least description
property must be shown from [DebotAction] structure.
action
: – Debot action to execute.
activity
: – DeBot activity details.
Debot Browser callbacks
action
: – Debot action that must be shown to user as menu item. At least description
property must be shown from [DebotAction] structure.
action
: – Debot action to execute.
activity
: – DeBot activity details.
Returning values from Debot Browser callbacks.
Parameters to start DeBot. DeBot must be already initialized with init() function.
debot_handle
: – Debot handle which references an instance of debot engine.
Parameters to fetch DeBot metadata.
info
: – Debot metadata.
Parameters for executing debot action.
debot_handle
: – Debot handle which references an instance of debot engine.
action
: – Debot Action that must be executed.
Parameters of send
function.
debot_handle
: – Debot handle which references an instance of debot engine.
debot_handle
: – Debot handle which references an instance of debot engine.
Debot Browser callbacks
action
: – Debot action that must be shown to user as menu item. At least description
property must be shown from [DebotAction] structure.
action
: – Debot action to execute.
activity
: – DeBot activity details.