Methods
Below is the list of all methods available in API object, methods return a promise of type APIResponse
Type: APIResponse
isEnabled
typhon.isEnabled():Promise<APIResponse>
Call this method to check if your dApp has access to Typhon
Response data will be
true
if already authorizedfalse
if not authorized
enable
typhon.enable():Promise<APIResponse>
Connect with Typhon, if not authorized before.
Response data will be
true
if approvedfalse
if rejected
getNetworkId
typhon.getNetworkId():Promise<APIResponse>
Response data will be NetworkId of the current active network
getBalance
typhon.getBalance():Promise<APIResponse>
Response data will be active account's balance, Below is the response data type
{
// Total ADA balance in Lovelace
ada: "12000000",
// Array of tokens
tokens: [{
policyId: "<hex PolicyId of token>",
assetName: "<hex AssetName of token>",
amount: "<Token Balance>"
}]
}
2
3
4
5
6
7
8
9
10
getAddress
typhon.getAddress():Promise<APIResponse>
Response data is the receiving BECH32 address of active account.
getRewardAddress
typhon.getRewardAddress():Promise<APIResponse>
Response data is the BECH32 reward address of active account.
getTransactionStatus
Use this method to check the status of a transaction after it's submitted.
typhon.getTransactionStatus(request: GetTransactionStatus): Promise<APIResponse>
request: Types.GetTransactionStatus
Result
{
[transactionId]: TransactionStatus,
}
2
3
TransactionStatus | when |
---|---|
PENDING | Transaction is in Pending State |
SUCCESS | Transaction is Successful |
FAILED | Transaction has failed |
Rate Limit
Please wait atleast 10 seconds before calling this method again.
paymentTransaction
Use this method for performing a simple send ADA/Token transaction. This can also be used to place a sell order for a token or interacting with a smart contract where locking is done by attaching a plutusData. Refer to the transaction type for details.
typhon.paymentTransaction(request: PaymentTransaction): Promise<APIResponse>
request: Types.PaymentTransaction
Result
when request.submit
is set to true
(default), On successful transaction submission, response data will be,
{
transactionId: string, // hex string
}
2
3
when request.submit
is set to false
, Response data will be,
{
cbor: string, // cbor hex string
}
2
3
delegationTransaction
To delegate to a stake pool
typhon.delegationTransaction(request: DelegationTransaction): Promise<APIResponse>
request: Types.DelegationTransaction
Result
On successful transaction submission, response data will be,
{
transactionId: string, // hex string
}
2
3
plutusTransaction
Use this method for interacting with plutus contract that requires redeemers, plutusData. It is only required to provide required plutus input, any necessary output if any. Typhon will add necessary change, fee, collateral, script integrity hash and required inputs automatically. Refer to the transaction type for specification.
typhon.plutusTransaction(request: PlutusTransaction): Promise<APIResponse>
request: Types.PlutusTransaction
Result
when request.submit
is set to true
(default), On successful transaction submission, response data will be,
{
transactionId: string, // hex string
}
2
3
when request.submit
is set to false
, Response data will be,
{
cbor: string, // cbor hex string
}
2
3
transaction
This method allows transactions with token minting via NativeScript, PlutusScript, and also allows you to provide any specific inputs. Note that the inputs are not mandatory, Typhon will process any necessary inputs required for the provided outputs and will also process necessary change output. As a developer, you can provide an input of the wallet or your own input to which you can add your own signature later. Eg. This method can be used for multi sig token minting, find the multisig example hereopen in new window.
typhon.transaction(request: Transaction): Promise<APIResponse>
request: Types.Transaction
Result
when request.submit
is set to true
(default), On successful transaction submission, response data will be,
{
transactionId: string, // hex string
}
2
3
when request.submit
is set to false
, Response data will be,
{
cbor: string, // cbor hex string
}
2
3
signData
Follows message signing CIP-0008open in new window to sign the data.
typhon.signData(request: DataSign): Promise<APIResponse>
request: Types.SignData
Result
Response data will be a cbor string of CoseSign1 message structure.
Error Handling
In case of failure response.error
will have SignDataError
type of object,
type SignDataError = {
code: SignDataErrorCode;
message: string; // error message
};
enum SignDataErrorCode {
InvalidAddress = "InvalidAddress",
InvalidData = "InvalidData",
}
2
3
4
5
6
7
8
9