Skip to content

docs: update dependencies #1196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ This library would not be possible without these rockstars.

## 📜 License

Copyright (c) 2024 StarkWare
Copyright (c) 2025 StarkWare

Licensed under the [MIT license](https://github.com/starknet-io/starknet.js/blob/main/LICENSE).
2 changes: 1 addition & 1 deletion __tests__/account.outsideExecution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ describe('Account and OutsideExecution', () => {
calldata: [getDecimalString(recipientAccount.address), '300', '0'],
},
]);
// get outside transaction of a multiCall :
// get outside transaction of a multiCall:
const outsideTransaction2: OutsideTransaction = await signerAccount.getOutsideTransaction(
callOptions,
[call1, call2]
Expand Down
4 changes: 2 additions & 2 deletions __tests__/utils/hash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ describe('getSelector', () => {

describe('L1->L2 messaging', () => {
// L1 tx for a message L1->L2
// data extracted from :
// data extracted from:
// https://sepolia.etherscan.io/tx/0xd82ce7dd9f3964d89d2eb9d555e1460fb7792be274950abe578d610f95cc40f5
// data extracted from etherscan :
// data extracted from etherscan:
const l1FromAddress = '0x0000000000000000000000008453fc6cd1bcfe8d4dfc069c400b433054d47bdc';
const l2ToAddress = 2158142789748719025684046545159279785659305214176670733242887773692203401023n;
const l2Selector = 774397379524139446221206168840917193112228400237242521560346153613428128537n;
Expand Down
2 changes: 1 addition & 1 deletion src/account/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export abstract class AccountInterface extends ProviderInterface {
* Estimate Fee for executing a list of transactions on starknet
* Contract must be deployed for fee estimation to be possible
*
* @param invocations array of transaction object containing :
* @param invocations array of transaction object containing:
* - type - the type of transaction : 'DECLARE' | (multi)'DEPLOY' | (multi)'INVOKE_FUNCTION' | 'DEPLOY_ACCOUNT'
* - payload - the payload of the transaction
*
Expand Down
6 changes: 3 additions & 3 deletions src/provider/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export abstract class ProviderInterface {
* @param {BigNumberish} l2TxHash L2 transaction hash
* @returns {string} Hex string of L1 message hash
* @example
* In Sepolia Testnet :
* In Sepolia Testnet:
* ```typescript
* const result = provider.getL1MessageHash('0x28dfc05eb4f261b37ddad451ff22f1d08d4e3c24dc646af0ec69fa20e096819');
* // result = '0x55b3f8b6e607fffd9b4d843dfe8f9b5c05822cd94fcad8797deb01d77805532a'
Expand Down Expand Up @@ -133,7 +133,7 @@ export abstract class ProviderInterface {
* Get the value of the storage (contract's variable) at the given address and key
*
* @param contractAddress
* @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
* @param key - from starknetKeccak()
* @param blockIdentifier - block identifier
* @returns the value of the storage variable
*/
Expand All @@ -147,7 +147,7 @@ export abstract class ProviderInterface {
* Gets the transaction information from a tx id.
*
* @param transactionHash
* @returns the transaction object \{ transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? \}
* @returns the transaction object `{ transaction_id, status, transaction, block_number?, transaction_index?, transaction_failure_reason? }`
*/
public abstract getTransaction(transactionHash: BigNumberish): Promise<GetTransactionResponse>;

Expand Down
2 changes: 1 addition & 1 deletion src/provider/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class RpcProvider implements ProviderInterface {

/**
* Pause the execution of the script until a specified block is created.
* @param {BlockIdentifier} blockIdentifier bloc number (BigNumberish) or 'pending' or 'latest'.
* @param {BlockIdentifier} blockIdentifier block number (BigNumberish) or 'pending' or 'latest'.
* Use of 'latest" or of a block already created will generate no pause.
* @param {number} [retryInterval] number of milliseconds between 2 requests to the node
* @example
Expand Down
2 changes: 1 addition & 1 deletion src/signer/ledgerSigner221.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class LedgerSigner221<Transport extends Record<any, any> = any>
* @param {LedgerPathCalculation} [pathFunction=getLedgerPathBuffer221]
* defines the function that will calculate the path. By default `getLedgerPathBuffer221` is selected.
*
* If you are using APP v2.2.1 with an account created with the v1.1.1, you need to use :
* If you are using APP v2.2.1 with an account created with the v1.1.1, you need to use:
* ```typescript
* const myLedgerSigner = new LedgerSigner211(myNodeTransport, 0, undefined, getLedgerPathBuffer111);
* ```
Expand Down
2 changes: 1 addition & 1 deletion src/types/lib/contract/abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type AbiEnum = {
type: 'enum';
};

// AbiEvents type is an arborescence :
// AbiEvents type is an arborescence:
// - Nodes are hashes of either Cairo 1 components names, or of Cairo 0 or 1 event names,
// - With Cairo 1 abi, the nodes are linked in accordance with the components arborescence ; the tree can have several levels of nodes.
// - With Cairo 0 abi : the tree has only one level of nodes (no component concept)
Expand Down
10 changes: 5 additions & 5 deletions src/utils/cairoDataTypes/uint256.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class CairoUint256 {
}

/**
* Validate if BigNumberish can be represented as Unit256
* Validate if BigNumberish can be represented as Uint256
*/
static validate(bigNumberish: BigNumberish) {
const bigInt = BigInt(bigNumberish);
Expand All @@ -65,7 +65,7 @@ export class CairoUint256 {
}

/**
* Validate if low and high can be represented as Unit256
* Validate if low and high can be represented as Uint256
*/
static validateProps(low: BigNumberish, high: BigNumberish) {
const bigIntLow = BigInt(low);
Expand All @@ -80,7 +80,7 @@ export class CairoUint256 {
}

/**
* Check if BigNumberish can be represented as Unit256
* Check if BigNumberish can be represented as Uint256
*/
static is(bigNumberish: BigNumberish) {
try {
Expand All @@ -107,7 +107,7 @@ export class CairoUint256 {

/**
* Return Uint256 structure with HexString props
* {low: HexString, high: HexString}
* `{low: HexString, high: HexString}`
*/
toUint256HexString() {
return {
Expand All @@ -118,7 +118,7 @@ export class CairoUint256 {

/**
* Return Uint256 structure with DecimalString props
* {low: DecString, high: DecString}
* `{low: DecString, high: DecString}`
*/
toUint256DecimalString() {
return {
Expand Down
11 changes: 5 additions & 6 deletions src/utils/calldata/byteArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ export function stringFromByteArray(myByteArray: ByteArray): string {
* @example
* ```typescript
* const myByteArray: ByteArray = byteArrayFromString("ABCDEFGHI");
* // result is: {
* // data: [],
* // pending_word: '0x414243444546474849',
* // pending_word_len: 9
* // }
* ```
* Result is :
* {
* data: [],
* pending_word: '0x414243444546474849',
* pending_word_len: 9
* }
*/
export function byteArrayFromString(targetString: string): ByteArray {
const shortStrings: string[] = splitLongString(targetString);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/calldata/enum/CairoCustomEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export type CairoEnumRaw = Record<string, any>;

/**
* Class to handle Cairo custom Enum
* @param enumContent object containing the variants and its content. Example :
* {Success: 234, Warning: undefined, Error: undefined}.
* @param enumContent object containing the variants and its content. Example:
* `{Success: 234, Warning: undefined, Error: undefined}`.
* Only one variant with a value, object, array.
* @returns an instance representing a Cairo custom Enum.
* @example
Expand Down
7 changes: 3 additions & 4 deletions src/utils/hash/transactionHash/v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ export function encodeResourceBoundsL1(bounds: ResourceBounds): bigint {

/**
* Encode the L2 bound of a V3 transaction
* @param {ResourceBounds} bounds
* {l1_gas: {max_amount: u64, max_price_per_unit: u128},
* l2_gas: {max_amount: u64, max_price_per_unit: u128}}
}
* @param {ResourceBounds} bounds
* `{l1_gas: {max_amount: u64, max_price_per_unit: u128},
* l2_gas: {max_amount: u64, max_price_per_unit: u128}}`
* @returns {bigint} encoded data
*/
export function encodeResourceBoundsL2(bounds: RPCSPEC07.ResourceBounds): bigint {
Expand Down
14 changes: 5 additions & 9 deletions src/utils/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,11 @@ export function getDefaultNodes(rpcVersion: SupportedRpcVersion) {
export const validBlockTags = Object.values(BlockTag);

/**
* This class is formatting the identifier of a block.
*
* hex string and BigInt are detected as block hashes. identifier return { block_hash: hash }
*
* decimal string and number are detected as block numbers. identifier return { block_number: number }
*
* text string are detected as block tag. identifier return tag
*
* null is detected as 'pending' block tag. identifier return 'pending'
* This class formats the identifier of a block.
* - hex strings and BigInts are detected as block hashes. identifier return `{ block_hash: hash }`
* - decimal strings and numbers are detected as block numbers. identifier return `{ block_number: number }`
* - text strings are detected as block tag. identifier return tag
* - null is detected as 'pending' block tag. identifier return 'pending'
* @example
* ```typescript
* const result = new provider.Block(null).identifier;
Expand Down
26 changes: 4 additions & 22 deletions www/ApiTitle.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Starknet.js API

This API is based on the <ins>[Starknet.js V3](https://github.com/starknet-io/starknet.js/discussions/102)</ins> Interface write up by <ins>[Janek](https://twitter.com/0xjanek)</ins> of <ins>[Argent](https://www.argent.xyz/)</ins>

## Provider

The Provider [**API**](./classes/Provider.md) allows you to interact with the Starknet network, without signing transactions or messages.
The Provider [**API**](./classes/RpcProvider.md) allows you to interact with the Starknet network, without signing transactions or messages.

Typically, these are _read_ calls on the blockchain.

Guide is [**here**](../guides/connect_network.md).

## Account

An Account extends <ins>[`Provider`](./classes/Provider)</ins> and inherits all of its methods.
An `Account` extends `Provider` and inherits all of its methods.

It also introduces new methods that allow Accounts to create and verify signatures with a custom <ins>[`Signer`](./classes/Signer)</ins>, declare and deploy Contract and deploy new Account

Expand All @@ -29,23 +31,3 @@ Guide is [**here**](../guides/create_contract.md).
## Signer

The Signer [**API**](./classes/Signer.md) allows you to sign transactions and messages, and also allows you to get the public key.

## Utils

Util functions are provided so you can use various low level functions in your application:

### [elliptic curve](./namespaces/ec.md)

### [hash](./namespaces/hash.md)

### [num](./namespaces/num.md)

### [encode](./namespaces/encode.md)

### [merkle](./namespaces/merkle.md)

### [shortString](./namespaces/shortString.md)

### [stark](./namespaces/stark.md)

### [uint256](./namespaces/uint256.md)
2 changes: 1 addition & 1 deletion www/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Website

This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.

## Installation

Expand Down
14 changes: 7 additions & 7 deletions www/docs/guides/L1message.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can exchange messages between L1 & L2 networks:
- L2 Starknet testnet ↔️ L1 Sepolia ETH testnet.
- L2 local Starknet devnet ↔️ L1 local ETH testnet (anvil, ...).

You can find an explanation of the global mechanism [here](https://docs.starknet.io/documentation/architecture_and_concepts/L1-L2_Communication/messaging-mechanism/).
You can find an explanation of the global mechanism [here](https://docs.starknet.io/architecture-and-concepts/network-architecture/messaging-mechanism/).

Most of the code for this messaging process will be written in Cairo, but Starknet.js provides some functionalities for this subject.

Expand Down Expand Up @@ -50,10 +50,10 @@ If the fee is paid in L1, the Cairo contract at `to_Address` is automatically ex

### L1 ➡️ L2 hashes

Starknet.js proposes 2 functions to calculate hashes related to a L1 ➡️ L2 message :
Starknet.js proposes 2 functions to calculate hashes related to a L1 ➡️ L2 message:

- The L2 message hash:
For a L1 tx requesting a message L1->L2, some data extracted from etherscan : https://sepolia.etherscan.io/tx/0xd82ce7dd9f3964d89d2eb9d555e1460fb7792be274950abe578d610f95cc40f5
For a L1 tx requesting a message L1->L2, some data extracted from etherscan: https://sepolia.etherscan.io/tx/0xd82ce7dd9f3964d89d2eb9d555e1460fb7792be274950abe578d610f95cc40f5

```typescript
const l1FromAddress = '0x0000000000000000000000008453fc6cd1bcfe8d4dfc069c400b433054d47bdc';
Expand All @@ -77,7 +77,7 @@ Starknet.js proposes 2 functions to calculate hashes related to a L1 ➡️ L2 m
// l1ToL2MessageHash = '0x2e350fa9d830482605cb68be4fdb9f0cb3e1f95a0c51623ac1a5d1bd997c2090'
```

Can be verified here : https://sepolia.starkscan.co/message/0x2e350fa9d830482605cb68be4fdb9f0cb3e1f95a0c51623ac1a5d1bd997c2090#messagelogs
Can be verified here: https://sepolia.starkscan.co/message/0x2e350fa9d830482605cb68be4fdb9f0cb3e1f95a0c51623ac1a5d1bd997c2090#messagelogs

- The L2 transaction hash:
For the same message:
Expand All @@ -92,7 +92,7 @@ Starknet.js proposes 2 functions to calculate hashes related to a L1 ➡️ L2 m
);
// l1ToL2TransactionHash = '0x67d959200d65d4ad293aa4b0da21bb050a1f669bce37d215c6edbf041269c07'
```
Can be verified here : https://sepolia.starkscan.co/tx/0x067d959200d65d4ad293aa4b0da21bb050a1f669bce37d215c6edbf041269c07
Can be verified here: https://sepolia.starkscan.co/tx/0x067d959200d65d4ad293aa4b0da21bb050a1f669bce37d215c6edbf041269c07

## L2 ➡️ L1 messages

Expand All @@ -112,12 +112,12 @@ The result is in `estimatedFee1`, of type BN.

### L2 ➡️ L1 hash

Starknet.js proposes a function to calculate the L1 ➡️ L2 message hash :
Starknet.js proposes a function to calculate the L1 ➡️ L2 message hash:

```typescript
const l2TransactionHash = '0x28dfc05eb4f261b37ddad451ff22f1d08d4e3c24dc646af0ec69fa20e096819';
const l1MessageHash = await provider.getL1MessageHash(l2TransactionHash);
// l1MessageHash = '0x55b3f8b6e607fffd9b4d843dfe8f9b5c05822cd94fcad8797deb01d77805532a'
```

Can be verified here : https://sepolia.voyager.online/tx/0x28dfc05eb4f261b37ddad451ff22f1d08d4e3c24dc646af0ec69fa20e096819#messages
Can be verified here: https://sepolia.voyager.online/tx/0x28dfc05eb4f261b37ddad451ff22f1d08d4e3c24dc646af0ec69fa20e096819#messages
16 changes: 8 additions & 8 deletions www/docs/guides/connect_network.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ Then you need to select a node. A node is a safe way to connect with the Starkne
> Main development devnets are Starknet-devnet-rs, Madara, ...

Each node is communicating with Starknet.js using a rpc specification. Most of the nodes are able to use 2 rpc spec versions.
For example, this node is compatible with v0.6.0 & v0.7.0, using the following entry points :
For example, this node is compatible with v0.6.0 & v0.7.0, using the following entry points:

- "https://free-rpc.nethermind.io/sepolia-juno/v0_6"
- "https://free-rpc.nethermind.io/sepolia-juno/v0_7"

From rpc spec v0.5.0, you can request the rpc spec version that uses a node address :
From rpc spec v0.5.0, you can request the rpc spec version that uses a node address:

```typescript
const resp = await myProvider.getSpecVersion();
console.log('rpc version =', resp);
// result : rpc version = 0.7.0
// result: rpc version = 0.7.0
```

On Starknet.js side, you have to select the proper version, to be in accordance with the node you want to use :
On Starknet.js side, you have to select the proper version, to be in accordance with the node you want to use:

| Rpc spec version of your node | Starknet.js version to use |
| :---------------------------: | ---------------------------- |
Expand Down Expand Up @@ -91,7 +91,7 @@ const providerAlchemyMainnet = new RpcProvider({
const providerMainnetNethermindPublic = new RpcProvider({
nodeUrl: 'https://free-rpc.nethermind.io/mainnet-juno/v0_7',
});
// Public Blast node rpc 0.7.0 for Mainnet (0.4, 0.5 & 0_6 also available) :
// Public Blast node rpc 0.7.0 for Mainnet (0.4, 0.5 & 0_6 also available):
const providerBlastMainnet = new RpcProvider({
nodeUrl: 'https://starknet-mainnet.public.blastapi.io/rpc/v0_7',
});
Expand All @@ -112,15 +112,15 @@ The Goerli testnet is no more in service.
### Sepolia Testnet

```typescript
// Infura node rpc 0.5.1 for Sepolia Testnet :
// Infura node rpc 0.5.1 for Sepolia Testnet:
const providerInfuraSepoliaTestnet = new RpcProvider({
nodeUrl: 'https://starknet-sepolia.infura.io/v3/' + infuraKey,
});
// Public Nethermind node rpc 0.7.0 for Sepolia Testnet (0_6 also available) :
// Public Nethermind node rpc 0.7.0 for Sepolia Testnet (0_6 also available):
const providerSepoliaTestnetNethermindPublic = new RpcProvider({
nodeUrl: 'https://free-rpc.nethermind.io/sepolia-juno/v0_7',
});
// Public Blast node rpc 0.7.0 for Sepolia Testnet (0_6 also available) :
// Public Blast node rpc 0.7.0 for Sepolia Testnet (0_6 also available):
const providerSepoliaTestnetBlastPublic = new RpcProvider({
nodeUrl: 'https://starknet-sepolia.public.blastapi.io/rpc/v0_7',
});
Expand Down
Loading
Loading