Client Integration
Last updated
Last updated
We will introduce some pieces of code in this section to help you make use of client integration. In this section, you can find the required functions written in JS or TS used to handle some specific operations within the Metis platform.
Note that all the client integration functions and code examples are for HTTP in JS or TS.
Creating a new instance of the HttpClient.
Return example for accessing the token and confirming the transaction.
Sending a transaction onto the blockchain and calling a function within the smart contract.
sendTx Return example:
Sending a transaction onto the blockchain asynchronously and calling a method within a smart contract.
An example of sending a transaction asynchronously.
Checking the final validity of a transaction before it is executed on chain.
Querying a transaction’s validity and calling a successful or an error message in execution.
queryTx Return Example:
Querying transactions’ validity asynchronously to return a promise.
queryTxAsync
Return Example:
Closing the dialog and calling the close() method without any parameters.
httpClient.closeConfirmDialogue();
Calling the error method and sending an error message to the console.
httpClient.error("Deployment Error");
Error return example:
["socket client runtime error!", "Deployment Error"]
Using the refreshToken
to obtain a new accessToken
. The callback function should be called and log the message “Successful Refresh” in the console.
Handling Refresh token asynchronously as input without any parameters.
await httpClient.handleRefreshTokenAsync()
Logging different variables.
// Passing string into the log function and logging them into the console
httpClient.log(["address: ", "0x11e575e473D552849b35d15A71C85bfFA511f45B"])
// Log return example
["address: ", "0x11e575e473D552849b35d15A71C85bfFA511f45B"]
Please feel free to reach out to our Help Center if you have any technical questions.
Parameter Name
Parameter Type
Parameter Description
appId
string
The Id of the specific application on the Polis application dashboard
accessToken
string
0Auth2 API access_token of your specific application
refreshToken
string
The token which refreshes the access_token
expiresIn
number
Integer of seconds until API access_token expires
apiHost
string
IP of access
Parameter Name
Parameter Type
Parameter Description
domain
string
Deployed smart contract name
chainid
number
Blockchain's chain ID that your contract is deployed on
fun
string
Name of the function to call within the deployed smart contract
args
array
Parameters to call the function above in order
succCallback?
function
The success function which is passed into the sendTx function to be called when execution is successful
errCallback?
function
The success function which is passed into the sendTx function to be called when execution results in an error
Parameter Name
Parameter Type
Parameter Description
domain
string
Deployed smart contract name
chainid
number
Blockchain's chain id that your contract is deployed on
fun
string
Name of the function that you are calling in the smart contract
args
array
Parameters that are needed to call the function above in order
Parameter Name
Parameter Type
Parameter Description
domain
string
Polis domain name
chainid
number
Blockchain's chain id that you deployed the contract on
address
string
Address of the caller of the transaction
fun
string
Name of the smart contract function called in this transaction
args
array
Parameters that are passed into the call of the function above
gas
string
The minimum gas for sending the tx on the blockchain
gasPrice
string
Gas price of the blockchain for the TX
fee
string
Gas fees for the specific TX
Parameter Name
Parameter Type
Parameter Description
chainid
number
The blockchain's chain ID that the contract is deployed on
tx
string
Specific transaction hash
succCallback?
function
The function that is passed into queryTx to be called
errCallback
function
The function that is passed into queryTx to be called
Parameter Name
Parameter Type
Parameter Description
chainid
number
The chain ID that the transaction is executed on
tx
string
The transaction hash
Parameter Name
Parameter Type
Parameter Description
msg
string
An error message that will be logged into the console
Parameter Name
Parameter Type
Parameter Description
callback?
function
A function that is passed into the handleRefreshtoken
Parameter Name
Parameter Type
Parameter Description
obj
array
An array of variables that will be logged into console
Return Type
Return Description
void
Does not return any value