Namespace: provider
Classes​
Variables​
validBlockTags​
• Const
validBlockTags: ("pending"
| "latest"
)[]
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​
getDefaultNodes​
â–¸ getDefaultNodes(rpcVersion
): any
return Defaults RPC Nodes endpoints
Parameters​
Name | Type |
---|---|
rpcVersion | "0.7.1" | "0.8.1" |
Returns​
any
Defined in​
getDefaultNodeUrl​
â–¸ getDefaultNodeUrl(networkName?
, mute?
, rpcVersion?
): string
Return randomly select available public node
Parameters​
Name | Type | Default value | Description |
---|---|---|---|
networkName? | "SN_MAIN" | "SN_SEPOLIA" | undefined | NetworkName |
mute | boolean | false | mute public node warning |
rpcVersion? | "0.7.1" | "0.8.1" | undefined | - |
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"