Constructor¶
constructor(extension)
Parameter
extension
-ExtensionWrapper
An instance of ExtensionWrapper. This is a pointer indicated to this class's holder.
Property¶
extension¶
Type: ExtensionWrapper
Description: ExtensionWrapper instance passed by constructor.
Methods¶
onChainCall¶
async onChainCall(wrapper, method, param, amount, extra)
Description
Invoke a smart contract's method to do some operation on blockchain. This method may change the state of blockchain.
Parameters :
wrapper
-ContractWrapper
:A ContractWrapper instance returned by loadContract method.
method
-String
:Which method in the contract will be called.
param
-Any
:Data for the contract method's parameter.
amount
-Number
:How much original token will send to the contract in this call.
extra
-Any
:Additional data required by extension.
Returns :
Promise<Result<String, Status>>
:Transaction hash will be set into the data field of Result if success.
offChainCall¶
async offChainCall(wrapper, method, param)
Description
Call smart contract and get the output or result whithout change the state of it.
Parameters :wrapper
-ContractWrapper
:A ContractWrapper instance returned by loadContract method.
method
-String
:Which method in the contract will be called.
param
-Any
:Data for the contract method's parameter.
Returns :
Value returned by the contract will be set into the data field of Result if success.