Skip to main content
Version: 4.22.0

Sequencer Provider

On top of methods found in the Provider section, SequencerProvider has some additional ones you can use.

Creating an instance

new starknet.SequencerProvider(optionsOrProvider)

The options for the provider depend on the network. The structure of the options object is:

  • options.baseUrl - Base URL of the network
  • options.feederGatewayUrl - Feeder Gateway Endpoint of the network
  • options.gatewayUrl - Gateway Endpoint
  • options.headers - [Optional] custom fetch headers

or

  • options.network - Either 'mainnet-alpha' or 'goerli-alpha'
  • options.headers - [Optional] custom fetch headers

Example:

const provider = new starknet.SequencerProvider({
baseUrl: 'https://alpha4.starknet.io',
feederGatewayUrl: 'feeder_gateway',
gatewayUrl: 'gateway',
})

Methods


getContractAddresses()

provider.getContractAddresses() => Promise < GetContractAddressesResponse >

Gets the smart contract address on the network.

GetContractAddressesResponse
{
Starknet: string;
GpsStatementVerifier: string;
}

getCode()

provider.getCode(contractAddress, blockIdentifier) => Promise < GetCodeResponse >

Gets the smart contract address on the network.

GetCodeResponse
{
bytecode: string[];
abi: Abi;
}

estimateMessageFee()

provider.estimateMessageFee(CallL1Handler, blockIdentifier) => Promise < EstimateFeeResponse >

Estimate fee for sending a message to L1.

CallL1Handler
type CallL1Handler = {
from_address: getDecimalString(from_address),
to_address: getHexString(to_address),
entry_point_selector: getSelector(entry_point_selector),
payload: getHexStringArray(payload),
};

###### _EstimateFeeResponse_

```typescript
{
overall_fee: number;
gas_price: number;
gas_usage: number;
unit: string;
}

getTransactionStatus()

provider.getTransactionStatus(txHash) => Promise < GetTransactionStatusResponse >

Gets the status of a transaction.

GetTransactionStatusResponse
{
tx_status: 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
block_hash: string;
tx_failure_reason?: {
tx_id: number;
code: string;
error_message: string;
}
}

getTransactionTrace()

provider.getTransactionTrace(txHash) => Promise < GetTransactionTraceResponse >

Gets the transaction trace from a tx hash.

GetTransactionTraceResponse
{
validate_invocation?: FunctionInvocation;
function_invocation?: FunctionInvocation;
fee_transfer_invocation?: FunctionInvocation;
signature: Signature;
}

{
FunctionInvocation: {
caller_address: string;
contract_address: string;
calldata: {
[inputName: string]: string | string[] | { type: 'struct'; [k: string]: BigNumberish };
};
call_type?: string;
class_hash?: string;
selector?: string;
entry_point_type?: EntryPointType;
result: Array<any>;
execution_resources: ExecutionResources;
internal_calls: Array<FunctionInvocation>;
events: Array<any>;
messages: Array<any>;
};
}

getBlockTraces()

provider.getBlockTraces(blockIdentifier) => Promise < BlockTransactionTracesResponse >

Gets the transaction traces of an entire block

BlockTransactionTracesResponse

{
traces: Array<TransactionTraceResponse & { transaction_hash: string }>;
}

{
TransactionTraceResponse: {
validate_invocation?: FunctionInvocation;
function_invocation?: FunctionInvocation;
fee_transfer_invocation?: FunctionInvocation;
signature: Signature;
};

FunctionInvocation: {
caller_address: string;
contract_address: string;
calldata: {
[inputName: string]: string | string[] | { type: 'struct'; [k: string]: BigNumberish };
};
call_type?: string;
class_hash?: string;
selector?: string;
entry_point_type?: EntryPointType;
result: Array<any>;
execution_resources: ExecutionResources;
internal_calls: Array<FunctionInvocation>;
events: Array<any>;
messages: Array<any>;
};
}