Class: TorqueRequestClient
Last updated
Last updated
@torque-labs/torque-ts-sdk • Docs
@torque-labs/torque-ts-sdk / TorqueRequestClient
The TorqueRequestClient class is used to make requests to the Torque API. It provides methods for performing API requests and handling responses.
Create a new instance of the TorqueRequestClient class.
Parameters
Parameter | Type |
---|---|
Returns
Throws
Throws an error if a signer is not provided.
Defined in
Perform a request to the Torque API.
Type Parameters
Parameters
Returns
Promise
<T
>
The response from the API.
Throws
If there is an error performing the request.
Defined in
Builds and returns a serialized transaction from the API based on the provided transaction input.
Type Parameters
Parameters
Returns
Promise
<T
& { serializedTx
: string
; }>
A promise that resolves with the serialized transaction.
Throws
Throws an error if the API is not able to build the transaction.
Defined in
Executes the serialized transaction using the API.
Parameters
Returns
Promise
<TxnExecuteResponse
>
A promise that resolves with the signature of the transaction.
Throws
Throws an error if the API request is unsuccessful or if the transaction fails.
Defined in
Perform a request to a Torque Function endpoint.
Type Parameters
Parameters
Returns
Promise
<T
>
The response from the API.
Throws
If there is an error performing the request.
Defined in
Signs a transaction with a Keypair.
Parameters
Returns
VersionedTransaction
The signed transaction.
Throws
If the signer is not initialized or if the signer is not a Keypair.
Defined in
Builds and executes the transaction using the Torque API.
Type Parameters
Parameters
Returns
Promise
<WithSignature
<T
>>
A promise that resolves with the signature of the transaction.
Defined in
Perform a regular request to any endpoint.
Type Parameters
Parameters
Returns
Promise
<T
>
The response from the API.
Throws
If there is an error performing the request.
Defined in
Property | Type |
---|---|
Type Parameter | Description |
---|---|
Parameter | Type | Description |
---|---|---|
Type Parameter | Description |
---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Type Parameter | Description |
---|---|
Parameter | Type | Description |
---|---|---|
Parameter | Type | Description |
---|---|---|
Type Parameter | Description |
---|---|
Parameter | Type | Description |
---|---|---|
Type Parameter | Description |
---|---|
Parameter | Type | Description |
---|---|---|
options
apiAuthHeader
Record
<string
, string
>
apiKey
undefined
| string
apiUrl
string
appUrl
string
connection
undefined
| Connection
functionsUrl
string
signer
undefined
| Adapter
| Keypair
signTransaction
undefined
| SignTransaction
T
The type of the response data.
url
string
The URL of the API endpoint.
options
?
RequestInit
The options for the request.
supressError
?
boolean
-
T
The type of the response data.
txnInput
{ data
: CreateCampaignInputSchema
; txnType
: CampaignCreate
; } | { data
: CampaignEndInputSchema
; txnType
: CampaignEnd
; } | { data
: PublisherCreateInputSchema
; txnType
: PublisherCreate
; } | { data
: PublisherPayoutInputSchema
; txnType
: PublisherPayout
; }
The input object of the transaction to build.
token
?
string
The Torque API token to use for the transaction.
txnExecuteInput
{ data
: { blockhash
: string
; campaignId
: string
; userSignature
: string
; }; txnType
: CampaignCreate
| CampaignEnd
; } | { data
: TxnExecuteDefaults
; txnType
: string
; }
The input object of the transaction to execute.
token
?
string
The Torque API token to use for the transaction.
T
The type of the response data.
url
string
The URL of the API endpoint.
options
?
RequestInit
The options for the request.
txn
VersionedTransaction
The transaction to sign.
T
The type of the response data.
txnInput
{ data
: CreateCampaignInputSchema
; txnType
: CampaignCreate
; } | { data
: CampaignEndInputSchema
; txnType
: CampaignEnd
; } | { data
: PublisherCreateInputSchema
; txnType
: PublisherCreate
; } | { data
: PublisherPayoutInputSchema
; txnType
: PublisherPayout
; }
The input object of the transaction to process.
token
?
string
The Torque API token to use for the transaction.
T
The type of the response data.
url
string
The URL of the API endpoint.
options
?
RequestInit
The options for the request.