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>
1

Call this method to check if your dApp has access to Typhon

Response data will be

  • true if already authorized
  • false if not authorized

enable

typhon.enable():Promise<APIResponse>
1

Connect with Typhon, if not authorized before.

Response data will be

  • true if approved
  • false if rejected

getNetworkId

typhon.getNetworkId():Promise<APIResponse>
1

Response data will be NetworkId of the current active network

getBalance

typhon.getBalance():Promise<APIResponse>
1

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>"
	}]
}
1
2
3
4
5
6
7
8
9
10

getAddress

typhon.getAddress():Promise<APIResponse>
1

Response data is the receiving BECH32 address of active account.

getRewardAddress

typhon.getRewardAddress():Promise<APIResponse>
1

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>
1

request: Types.GetTransactionStatus

Result

{
	[transactionId]: TransactionStatus,
}
1
2
3
TransactionStatuswhen
PENDINGTransaction is in Pending State
SUCCESSTransaction is Successful
FAILEDTransaction 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>
1

request: Types.PaymentTransaction

Result

when request.submit is set to true(default), On successful transaction submission, response data will be,

{
	transactionId: string,  // hex string
}
1
2
3

when request.submit is set to false, Response data will be,

{
	cbor: string, // cbor hex string
}
1
2
3

delegationTransaction

To delegate to a stake pool

typhon.delegationTransaction(request: DelegationTransaction): Promise<APIResponse>
1

request: Types.DelegationTransaction

Result

On successful transaction submission, response data will be,

{
	transactionId: string,  // hex string
}
1
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>
1

request: Types.PlutusTransaction

Result

when request.submit is set to true (default), On successful transaction submission, response data will be,

{
	transactionId: string,  // hex string
}
1
2
3

when request.submit is set to false, Response data will be,

{
	cbor: string, // cbor hex string
}
1
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>
1

request: Types.Transaction

Result

when request.submit is set to true (default), On successful transaction submission, response data will be,

{
	transactionId: string,  // hex string
}
1
2
3

when request.submit is set to false, Response data will be,

{
	cbor: string, // cbor hex string
}
1
2
3

signData

Follows message signing CIP-0008open in new window to sign the data.

typhon.signData(request: DataSign): Promise<APIResponse>
1

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",
}
1
2
3
4
5
6
7
8
9