Namespace: provider
Classes​
Variables​
validBlockTags​
• Const
validBlockTags: BlockTag
[]
Defined in​
Functions​
wait​
â–¸ wait(delay
): Promise
<unknown
>
Helper - Async Sleep for 'delay' time
Parameters​
Name | Type | Description |
---|---|---|
delay | number | Number of milliseconds to delay |
Returns​
Promise
<unknown
>
Example
await provider.wait(1000); // 1000 milliseconds == 1 second
Defined in​
createSierraContractClass​
â–¸ createSierraContractClass(contract
): SierraContractClass
Create Sierra compressed Contract Class from a given Compiled Sierra
CompiledSierra -> SierraContractClass
Parameters​
Name | Type | Description |
---|---|---|
contract | CompiledSierra | sierra code from the Cairo compiler |
Returns​
compressed Sierra
Example
const result = provider.createSierraContractClass({
"sierra_program": [
"0x1",
"0x4",
"0x0",
"0x2",
"0x4",
"0x1",
"0x3b4",
"0x4c",
"0x65",
"0x52616e6765436865636b",...})
// result = {sierra_program: 'H4sIAAAAAAAAA6x9WZbsrI7uVGqd53qgb8ZynwzYY7jDv5JAAmxHZuQ+96yq/L0jIzEINZ8axP/5j/q/+j//+z/wH9f/o/p/zPbh+Iot49+u9v8G3//rTdDhDDF4Z0MKPthQ+m+S2v6n1S//638VvdXW2PQ6RvxuDG+jiybCXKJ7Hef6ZRi9E+Q89WmKLilfqbrsL6PUCf8...}
Defined in​
parseContract​
â–¸ parseContract(contract
): ContractClass
Create a compressed contract from a given compiled Cairo 0 & 1 contract or a string.
Parameters​
Name | Type | Description |
---|---|---|
contract | string | CompiledContract | Compiled Cairo 0 or Cairo 1 contract, or string |
Returns​
Cairo 0 or Cairo 1 compressed contract
Example
const result = provider.parseContract({
"sierra_program": [
"0x1",
"0x4",
"0x0",
"0x2",
"0x4",
"0x1",
"0x3b4",
"0x4c",
"0x65",
"0x52616e6765436865636b",...})
// result = {sierra_program: 'H4sIAAAAAAAAA6x9WZbsrI7uVGqd53qgb8ZynwzYY7jDv5JAAmxHZuQ+96yq/L0jIzEINZ8axP/5j/q/+j//+z/wH9f/o/p/zPbh+Iot49+u9v8G3//rTdDhDDF4Z0MKPthQ+m+S2v6n1S//638VvdXW2PQ6RvxuDG+jiybCXKJ7Hef6ZRi9E+Q89WmKLilfqbrsL6PUCf8...}
Defined in​
isV3Tx​
â–¸ isV3Tx(details
): details is V3TransactionDetails
Check if the given transaction details is a V3 transaction.
Parameters​
Name | Type | Description |
---|---|---|
details | InvocationsDetailsWithNonce | The transaction details to be checked. |
Returns​
details is V3TransactionDetails
Returns true if the transaction is a V3 transaction, otherwise false.
Example
const invocation: InvocationsDetailsWithNonce = {
nonce: 1,
version: 3,
maxFee: 10 ** 15,
feeDataAvailabilityMode: RPC.EDataAvailabilityMode.L1,
tip: 10 ** 13,
paymasterData: [],
resourceBounds: {
l1_gas: { max_amount: num.toHex(10 ** 14), max_price_per_unit: num.toHex(50) },
l2_gas: { max_amount: num.toHex(0), max_price_per_unit: num.toHex(0) },
},
};
const result = provider.isV3Tx(invocation);
// result = true
Defined in​
isVersion​
â–¸ isVersion(version
, response
): boolean
Determines if the given response matches the specified version.
Parameters​
Name | Type | Description |
---|---|---|
version | "0.5" | "0.6" | "0.7" | The version to compare against the response. |
response | string | The response to check against the version. |
Returns​
boolean
True if the response matches the version, false otherwise.
Example
const result = provider.isVersion('0.7', '0_7');
// result = false
Defined in​
isPendingBlock​
â–¸ isPendingBlock(response
): response is PendingBlock
Guard Pending Block
Parameters​
Name | Type | Description |
---|---|---|
response | GetBlockResponse | answer of myProvider.getBlock() |
Returns​
response is PendingBlock
true if block is the pending block
Example
const block = await myProvider.getBlock('pending');
const result = provider.isPendingBlock(block);
// result = true
Defined in​
isPendingTransaction​
â–¸ isPendingTransaction(response
): boolean
Guard Pending Transaction
Parameters​
Name | Type | Description |
---|---|---|
response | GetTransactionReceiptResponse | transaction Receipt |
Returns​
boolean
true if the transaction is part of the pending block
Example
const block = await myProvider.getBlockWithTxs('pending');
const txR = await myProvider.getTransactionReceipt(block.transactions[0].transaction_hash);
const result = provider.isPendingTransaction(txR);
// result = true
Defined in​
isPendingStateUpdate​
â–¸ isPendingStateUpdate(response
): response is Object
Guard Pending State Update
Parameters​
Name | Type | Description |
---|---|---|
response | StateUpdateResponse | State of a block |
Returns​
response is Object
true if the block is pending
Example
const state: StateUpdateResponse = await myProvider.getStateUpdate('pending');
const result = provider.isPendingStateUpdate(state);
// result = true
Defined in​
getDefaultNodeUrl​
â–¸ getDefaultNodeUrl(networkName?
, mute?
): string
Return randomly select available public node
Parameters​
Name | Type | Default value | Description |
---|---|---|---|
networkName? | NetworkName | undefined | NetworkName |
mute | boolean | false | mute public node warning |
Returns​
string
default node url
Example
const result = provider.getDefaultNodeUrl(constants.NetworkName.SN_MAIN, false);
// console : "Using default public node url, please provide nodeUrl in provider options!"
// result = "https://starknet-mainnet.public.blastapi.io/rpc/v0_7"