Skip to main content
Version: Next

Class: PaymasterRpc

Implements

Constructors

constructor

new PaymasterRpc(options?): PaymasterRpc

Parameters

NameType
options?PaymasterOptions | PaymasterInterface | PaymasterRpc

Returns

PaymasterRpc

Defined in

src/paymaster/rpc.ts:84

Properties

nodeUrl

nodeUrl: string

Implementation of

PaymasterInterface.nodeUrl

Defined in

src/paymaster/rpc.ts:76


headers

headers: object

Implementation of

PaymasterInterface.headers

Defined in

src/paymaster/rpc.ts:78


baseFetch

Readonly baseFetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>

Type declaration

▸ (input, init?): Promise<Response>

Parameters
NameType
inputRequestInfo | URL
init?RequestInit
Returns

Promise<Response>

Implementation of

PaymasterInterface.baseFetch

Defined in

src/paymaster/rpc.ts:80


requestId

requestId: number

Defined in

src/paymaster/rpc.ts:82

Methods

fetch

fetch(method, params?, id?): Promise<Response>

Parameters

NameTypeDefault value
methodstringundefined
params?objectundefined
idstring | number0

Returns

Promise<Response>

Defined in

src/paymaster/rpc.ts:114


errorHandler

errorHandler(method, params, rpcError?, otherError?): void

Parameters

NameType
methodstring
paramsany
rpcError?Error
otherError?any

Returns

void

Defined in

src/paymaster/rpc.ts:128


fetchEndpoint

fetchEndpoint<T>(method, params?): Promise<Methods[T][``"result"``]>

Type parameters

NameType
Textends keyof ReadMethods | "paymaster_executeTransaction"

Parameters

NameType
methodT
params?Methods[T][``"params"``]

Returns

Promise<Methods[T][``"result"``]>

Defined in

src/paymaster/rpc.ts:140


isAvailable

isAvailable(): Promise<boolean>

Returns the status of the paymaster service

Returns

Promise<boolean>

If the paymaster service is correctly functioning, return true. Else, return false

Implementation of

PaymasterInterface.isAvailable

Defined in

src/paymaster/rpc.ts:156


buildTransaction

buildTransaction(transaction, parameters): Promise<PreparedTransaction>

Receives the transaction the user wants to execute. Returns the typed data along with the estimated gas cost and the maximum gas cost suggested to ensure execution

Parameters

NameTypeDescription
transactionUserTransactionTransaction to be executed by the paymaster
parametersExecutionParametersExecution parameters to be used when executing the transaction

Returns

Promise<PreparedTransaction>

The transaction data required for execution along with an estimation of the fee

Implementation of

PaymasterInterface.buildTransaction

Defined in

src/paymaster/rpc.ts:160


executeTransaction

executeTransaction(transaction, parameters): Promise<ExecuteResponse>

Sends the signed typed data to the paymaster service for execution

Parameters

NameTypeDescription
transactionExecutableUserTransactionTyped data build by calling paymaster_buildTransaction signed by the user to be executed by the paymaster service
parametersExecutionParametersExecution parameters to be used when executing the transaction

Returns

Promise<ExecuteResponse>

The hash of the transaction broadcasted by the paymaster and the tracking ID corresponding to the user execute request

Implementation of

PaymasterInterface.executeTransaction

Defined in

src/paymaster/rpc.ts:238


getSupportedTokens

getSupportedTokens(): Promise<TokenData[]>

Get a list of the tokens that the paymaster supports, together with their prices in STRK

Returns

Promise<TokenData[]>

An array of token data

Implementation of

PaymasterInterface.getSupportedTokens

Defined in

src/paymaster/rpc.ts:282