Types
APIResponse
return type of method
type APIResponse = {
status: boolean;
reason?: REASON;
error?: unknown;
data?: unknown;
};
1
2
3
4
5
6
2
3
4
5
6
status
will betrue
for successful response,false
for any type of failure or error.
Success
If status
is true, that means API has executed successfully, and response will be available in data
property.
Failure
if status
is false that means API has failed, and It could be of any REASON
specified below,
REASON | When |
---|---|
ABORT | When transaction notification is closed by user or any action taken by System. |
REJECT | When request is Unauthorized or user rejects the request. |
ERROR | When API could not be processed due to an error, Error will be available in error property. |
Request
Section defines the types for request data to execute a transaction
GetTransactionStatus
type GetTransactionStatus = Array<string>; // Array of TransactionId
1
PaymentTransaction
type PaymentTransaction = {
outputs: Array<TransactionOutput>;
auxiliaryDataCbor?: string; // cbor hex string
submit?: boolean;
};
1
2
3
4
5
2
3
4
5
- auxiliaryDataCbor - generate using typhonjsopen in new window or cardano-cli
- submit
default: true
- Set this tofalse
to not submit the transaction to network and instead get transaction CBOR as response.
DelegationTransaction
type DelegationTransaction = {
poolId: string; // hex or bech32
};
1
2
3
2
3
PlutusTransaction
type PlutusTransaction = {
inputs: Array<PlutusScriptInput>;
outputs?: Array<TransactionOutput>;
requiredSigners?: [string]; // hex string
auxiliaryDataCbor?: string; // cbor hex string
submit?: boolean;
};
1
2
3
4
5
6
7
2
3
4
5
6
7
- auxiliaryDataCbor - generate using typhonjsopen in new window or cardano-cli
- inputs - provide plutus script input with plutusData, redeemers. The required utxos, change address etc will be fulfilled by Typhon
- output - Optional, if you need a specific output to be in the transaction.
- requiredSigners - provide requiredSigners publicKeyHash hex value if any, these will be added in the tx cbor, and additional signatures will be added if the requiredSigner contains a wallet publicKeyHash
- submit
default: true
- Set this tofalse
to not submit the transaction to network and instead get transaction CBOR as response.
Transaction
type Transaction = {
inputs?: Array<TransactionInput>;
plutusInputs?: Array<PlutusScriptInput>;
outputs?: Array<TransactionOutput>;
mints?: Array<Mint>;
requiredSigners?: Array<string>;
submit?: boolean;
auxiliaryDataCbor?: string;
};
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
- auxiliaryDataCbor - generate using typhonjsopen in new window or cardano-cli
- inputs - Optional, if you need a specific input to be present in the transaction, or add your own input to which you can add witness for on your end later for multisig purpose.
- plutusInputs - provide plutus script input with plutusData, redeemers. The required utxos, change address etc will be fulfilled by Typhon
- output - Optional, if you need a specific output to be in the transaction.
- mints - Provide a mint of burn for tokens, you can mint tokens with NativeScript and PlutusScript. You can add your signature to the tx on your end if required using submit: false options.
- requiredSigners - provide requiredSigners publicKeyHash hex value if any, these will be added in the tx cbor, and additional signatures will be added if the requiredSigner contains a wallet publicKeyHash
- submit
default: true
- Set this tofalse
to not submit the transaction to network and instead get transaction CBOR as response.
SignData
type SignData = {
address: string; // bech32
data: string; // hex data
};
1
2
3
4
2
3
4
General
TransactionOutput
type TransactionOutput = {
address: string; // bech32
amount?: string; // Lovelace string
tokens?: Array<Token>;
plutusDataCbor?: string; // cbor hex string
plutusDataHash?: string; // hex string
};
1
2
3
4
5
6
7
2
3
4
5
6
7
- plutusDataCbor - generate using typhonjsopen in new window or cardano-cli
- address is bech32 string
- If plutusData is supplied, the plutusData and its hash both will be embedded in the output
- If both plutusData and plutusDataHash is supplied, the plutusData and it's hash will be used
- If no amount is supplied, minimum utxo amount will be used
TransactionInput
type TransactionInput = {
txId: string;
index: number;
};
1
2
3
4
2
3
4
Mint
type Mint = {
policyId: string; // hex value
assets: Array<Asset>;
nativeScript?: NativeScript;
plutusScript?: PlutusScript;
redeemer?: Redeemer;
};
1
2
3
4
5
6
7
2
3
4
5
6
7
PlutusScriptType
Only PlutusScriptV1 is supported as of now
enum PlutusScriptType {
PlutusScriptV1 = "PlutusScriptV1",
}
1
2
3
2
3
PlutusScriptInput
type PlutusScriptInput = {
txId: string;
index: number;
plutusDataCbor: string; // cbor hex string
redeemer: Redeemer;
paymentScript: {
cborHex: string; // cbor hex string
type: PlutusScriptType;
};
stakeScript?: {
cborHex: string; // cbor hex string
type: PlutusScriptType;
};
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
- plutusDataCbor - generate using typhonjsopen in new window or cardano-cli
- paymentScript.cborHex is the cbor hex as available after building a plutus contract, the first part of the contract address
- stakeScript - if the second part of the address is also a plutus script, and if the address is a Base address, Normally this is not used
NativeScript
type NativeScript =
| NativeScriptPubKeyHash
| NativeScriptInvalidBefore
| NativeScriptNOfK
| NativeScriptInvalidAfter
| NativeScriptAll
| NativeScriptAny;
1
2
3
4
5
6
7
2
3
4
5
6
7
type NativeScriptPubKeyHash = {
pubKeyHash: string;
};
1
2
3
2
3
type NativeScriptInvalidBefore = {
invalidBefore: number;
};
1
2
3
2
3
type NativeScriptNOfK = {
n: number;
k: Array<NativeScript>;
};
1
2
3
4
2
3
4
type NativeScriptInvalidAfter = {
invalidAfter: number;
};
1
2
3
2
3
type NativeScriptAll = {
all: Array<NativeScript>;
};
1
2
3
2
3
type NativeScriptAny = {
any: Array<NativeScript>;
};
1
2
3
2
3
PlutusScript
type PlutusScript = {
cborHex: string;
type: PlutusScriptType;
};
1
2
3
4
2
3
4
ExUnits
type ExUnits = {
mem: number;
steps: number;
};
1
2
3
4
2
3
4
- provide steps and mem as per estimation
Redeemer
type Redeemer = {
plutusDataCbor: string; // cbor hex string
exUnits: ExUnits; // estimated ex units
};
1
2
3
4
2
3
4
- plutusDataCbor - generate using typhonjsopen in new window or cardano-cli
Token
type Token = {
policyId: string; // hex value
assetName: string; // hex value
amount: string; // value
};
1
2
3
4
5
2
3
4
5
Asset
type Asset = {
assetName: string; // hex value
amount: string; // value
};
1
2
3
4
2
3
4
NetworkId
Typhon supports 2 networks, Mainnet and Testnet. Below is the mapping between the network and NetworkId
Network Name | NetworkId |
---|---|
Mainnet | 1 |
Testnet | 0 |