starknet 3.10.1 → 3.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [3.10.2](https://github.com/seanjameshan/starknet.js/compare/v3.10.1...v3.10.2) (2022-04-27)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **tests:** fix getBlock blocks ([c0422b7](https://github.com/seanjameshan/starknet.js/commit/c0422b7d963639d34082731f6efbe3f0dd2c3c4d))
6
+
1
7
  ## [3.10.1](https://github.com/seanjameshan/starknet.js/compare/v3.10.0...v3.10.1) (2022-04-20)
2
8
 
3
9
  ### Bug Fixes
@@ -10,15 +10,15 @@ describe('defaultProvider', () => {
10
10
  expect(typeof GpsStatementVerifier).toBe('string');
11
11
  expect(typeof Starknet).toBe('string');
12
12
  });
13
- test('getBlock(blockHash=0x3bca19c3d5983e21e9537669b15f951f0664f0747a083dc714e0b9648b8575d, blockNumber=undefined)', () => {
13
+ test('getBlock(blockHash=0x26e33ad2807590b93e98a04e703d7d64d4ead13591b50984ae558bdbe8fbcd2, blockNumber=undefined)', () => {
14
14
  return expect(
15
15
  defaultProvider.getBlock(
16
- '0x3bca19c3d5983e21e9537669b15f951f0664f0747a083dc714e0b9648b8575d'
16
+ '0x26e33ad2807590b93e98a04e703d7d64d4ead13591b50984ae558bdbe8fbcd2'
17
17
  )
18
18
  ).resolves.not.toThrow();
19
19
  });
20
- test('getBlock(blockHash=undefined, blockNumber=36657)', () => {
21
- return expect(defaultProvider.getBlock(36657)).resolves.not.toThrow();
20
+ test('getBlock(blockHash=undefined, blockNumber=168890)', () => {
21
+ return expect(defaultProvider.getBlock(168890)).resolves.not.toThrow();
22
22
  });
23
23
  test('getBlock(blockHash=undefined, blockNumber=null)', () => {
24
24
  return expect(defaultProvider.getBlock()).resolves.not.toThrow();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starknet",
3
- "version": "3.10.1",
3
+ "version": "3.10.2",
4
4
  "description": "JavaScript library for StarkNet",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +1,5 @@
1
-
2
1
  // Install the latest version of starknet with npm install starknet@next and import starknet
3
- import * as starknet from "starknet";
2
+ import * as starknet from 'starknet';
4
3
 
5
4
  // Generate public and private key pair.
6
5
 
@@ -8,7 +7,11 @@ const keyPair = starknet.ec.genKeyPair();
8
7
  const starkKey = starknet.ec.getStarkKey(keyPair);
9
8
  const starkKeyInt = starknet.number.toBN(starknet.encode.removeHexPrefix(starkKey), 16);
10
9
 
11
- const { address: walletAddressLocal } = await provider.deployContract({contract: COMPILED_WALLET_CONTRACT_JSON, constructorCallData: [starkKeyInt], addressSalt: 0});
10
+ const { address: walletAddressLocal } = await provider.deployContract({
11
+ contract: COMPILED_WALLET_CONTRACT_JSON,
12
+ constructorCallData: [starkKeyInt],
13
+ addressSalt: 0,
14
+ });
12
15
 
13
16
  walletAddress = walletAddressLocal;
14
17
 
@@ -28,7 +31,7 @@ const balanceBeforeTransfer = await erc20.call('balance_of', {
28
31
  user: walletAddress,
29
32
  }).res;
30
33
 
31
- console.log(number.toBN(res).toString())
34
+ console.log(number.toBN(res).toString());
32
35
 
33
36
  const { nonce } = await wallet.call('get_nonce');
34
37
  const msgHash = encode.addHexPrefix(
@@ -59,4 +62,4 @@ const balanceAfterTransfer = await erc20.call('balance_of', {
59
62
  user: walletAddress,
60
63
  }).res;
61
64
 
62
- console.log('Balance after transfer', balanceAfterTransfer)
65
+ console.log('Balance after transfer', balanceAfterTransfer);
@@ -1,37 +1,33 @@
1
1
  import { defaultProvider, stark } from 'starknet';
2
2
  const { getSelectorFromName } = stark;
3
3
 
4
-
5
4
  /**
6
5
  * !! IMPORTANT NOTE !! When fees are introduced all function invocations will go through the account account contract and this example will be deprecated.
7
- **/
6
+ **/
8
7
 
9
- const CONTRACT_ADDRESS =
10
- "0x03e19baa6cb2078631bcdb34844f3f7879449a544c9ce722681a54af08cff4b9";
8
+ const CONTRACT_ADDRESS = '0x03e19baa6cb2078631bcdb34844f3f7879449a544c9ce722681a54af08cff4b9';
11
9
 
12
10
  /**
13
11
  * invokeFunction() example
14
- **/
12
+ **/
15
13
 
16
14
  /** Reset the liquidity pool **/
17
- const addLiquidityResponse = await defaultProvider.LEGACYinvokeFunction(
18
- {
19
- contractAddress: CONTRACT_ADDRESS,
20
- entrypoint: "init_pool",
21
- calldata: ["1000000", "1000000"],
22
- }
23
- );
15
+ const addLiquidityResponse = await defaultProvider.LEGACYinvokeFunction({
16
+ contractAddress: CONTRACT_ADDRESS,
17
+ entrypoint: 'init_pool',
18
+ calldata: ['1000000', '1000000'],
19
+ });
24
20
  console.log(addLiquidityResponse);
25
21
 
26
22
  /**
27
23
  * callContract() example
28
- **/
24
+ **/
29
25
 
30
26
  /** Get the balance of the liquidity pool of token A **/
31
27
  const poolBalanceTokenA = await defaultProvider.callContract({
32
28
  contractAddress: CONTRACT_ADDRESS,
33
- entrypoint: "get_pool_token_balance",
34
- calldata: ["1"], // Account 1 (no account implemented)
29
+ entrypoint: 'get_pool_token_balance',
30
+ calldata: ['1'], // Account 1 (no account implemented)
35
31
  });
36
32
  const balanceA = poolBalanceTokenA.result[0];
37
33
  console.log('token a liquidity pool balance: ', parseInt(balanceA, 16));
@@ -39,11 +35,10 @@ console.log('token a liquidity pool balance: ', parseInt(balanceA, 16));
39
35
  /** Get the balance of the liquidity pool of token B **/
40
36
  const poolBalanceTokenB = await defaultProvider.callContract({
41
37
  contractAddress: CONTRACT_ADDRESS,
42
- entrypoint: "get_pool_token_balance",
43
- calldata: ["2"],
38
+ entrypoint: 'get_pool_token_balance',
39
+ calldata: ['2'],
44
40
  });
45
41
  const balanceB = poolBalanceTokenB.result[0];
46
42
  console.log('token b liquidity pool balance: ', parseInt(balanceB, 16));
47
43
 
48
-
49
44
  /** Make a swap */
@@ -1,10 +1,13 @@
1
- import * as starknet from "starknet";
1
+ import * as starknet from 'starknet';
2
2
 
3
3
  const keyPair = starknet.ec.genKeyPair();
4
4
  const starkKey = starknet.ec.getStarkKey(keyPair);
5
5
  const starkKeyInt = starknet.number.toBN(starknet.encode.removeHexPrefix(starkKey), 16);
6
6
 
7
- const deployWalletTx = await provider.deployContract({contract: COMPILED_WALLET_CONTRACT_JSON, constructorCallData: [starkKeyInt], addressSalt: 0});
7
+ const deployWalletTx = await provider.deployContract({
8
+ contract: COMPILED_WALLET_CONTRACT_JSON,
9
+ constructorCallData: [starkKeyInt],
10
+ addressSalt: 0,
11
+ });
8
12
 
9
13
  await defaultProvider.waitForTx(deployWalletTx.transaction_hash);
10
-
@@ -9,3 +9,97 @@ An Account extends <ins>[`Provider`](/docs/API/provider)</ins> and inherits all
9
9
  It also introduces new methods that allow Accounts to create and verify signatures with a custom <ins>[`Signer`](/docs/API/signer)</ins>.
10
10
 
11
11
  This API is the primary way to interact with an account contract on StarkNet.
12
+
13
+ ## Creating an instance
14
+
15
+ For creating new instance of Account, account contract must be deployed. Also there needs to be a Provider instance that will be passed in the constructor and key pair for the account.
16
+
17
+ `new starknet.Account(Provider, address, starkKeyPair)`
18
+
19
+ ## Account Properties
20
+
21
+ contract.**address** => _string_
22
+
23
+ The address of the account contract
24
+
25
+ ## Account methods
26
+
27
+ account.**getNonce()** => _Promise < string >_
28
+
29
+ Gets new Nonce for the next transaction
30
+
31
+ <hr />
32
+
33
+ account.**estimateFee**(calls [ , options ]) => _Promise < EstimateFeeResponse >_
34
+
35
+ Gets the estimated fee for the call(s)
36
+
37
+ The _options_ object may include any of:
38
+
39
+ - options.**blockIdentifier** - Block Identifier for the transaction
40
+ - options.**nonce** - Nonce for the transaction
41
+
42
+ ###### EstimateFeeResponse
43
+
44
+ ```
45
+ {
46
+ amount: number;
47
+ unit: string;
48
+ }
49
+ ```
50
+
51
+ <hr />
52
+
53
+ account.**execute**(calls [ , abi , transactionsDetail ]) => _Promise < AddTransactionResponse >_
54
+
55
+ Executes one or multiple calls using the account contract
56
+
57
+ The _transactionsDetail_ object may include any of:
58
+
59
+ - transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
60
+ - transactionsDetail.**nonce** - Nonce for the transaction
61
+ - transactionsDetail.**version** - Version for the transaction (default is 0)
62
+
63
+ ###### AddTransactionResponse
64
+
65
+ ```
66
+ {
67
+ code: 'TRANSACTION_RECEIVED';
68
+ transaction_hash: string;
69
+ address?: string;
70
+ };
71
+ ```
72
+
73
+ <hr />
74
+
75
+ account.**signMessage**(typedData) => _Promise < Signature >_
76
+
77
+ Creates a signature from the passed data
78
+
79
+ ###### Signature
80
+
81
+ ```
82
+ string[];
83
+ ```
84
+
85
+ <hr />
86
+
87
+ account.**hashMessage**(typedData) => _Promise < string >_
88
+
89
+ Creates a hash from the passed data
90
+
91
+ <hr />
92
+
93
+ account.**verifyMessageHash**(hash, signature) => _Promise < boolean >_
94
+
95
+ Verify a signature of a given hash
96
+
97
+ **WARNING** This method is not recommended, use verifyMessage instead
98
+
99
+ <hr />
100
+
101
+ account.**verifyMessage**(typedData, signature) => _Promise < boolean >_
102
+
103
+ Verify a signature of a JSON object
104
+
105
+ <hr />
@@ -0,0 +1,15 @@
1
+ ---
2
+ sidebar_position: 6
3
+ ---
4
+
5
+ # CHANGELOG
6
+
7
+ ### Release 3.10.2 (21.04.2022)
8
+
9
+ - New hash formula for the new account contract version.
10
+
11
+ **NOTE**: Update your accounts, old ones will not be supported anymore. For updating with Argent X extension you can check this [link](https://github.com/argentlabs/argent-x/pull/522)
12
+
13
+ - BUGFIX: [#165](https://github.com/0xs34n/starknet.js/issues/165)
14
+ - BUGFIX: [#151](https://github.com/0xs34n/starknet.js/issues/151)
15
+ - BUGFIX: [#158](https://github.com/0xs34n/starknet.js/issues/158)
@@ -8,7 +8,78 @@ Contracts can do data transformations in JavaScript based on an ABI. They can al
8
8
 
9
9
  Contracts allow you to transform Cairo values, like `Uint256` to `BigNumber`. It could also allow users to pass their own transformers, similar to `JSON.parse`.
10
10
 
11
- ## Contract Factory
11
+ ## Creating an instance
12
12
 
13
- Contract Factory allow you to deploy contracts onto StarkNet
13
+ `new starknet.Contract(abi, address, providerOrAccount)`
14
14
 
15
+ `contract.attach(providerOrAccount)` _for changing the provider or account_
16
+
17
+ `contract.connect(providerOrAccount)` _for changing the address of the connected contract_
18
+
19
+ ## Contract properties
20
+
21
+ contract.**address** => _string_
22
+
23
+ The address the contract was constructed/connected with
24
+
25
+ contract.**providerOrAcount** => _Provider | Account_
26
+
27
+ Provider or Account that are used to interact with the network
28
+
29
+ contract.**deployTransactionHash** => _string | null_
30
+
31
+ If the Contract object is the result of a ContractFactory deployment, this is the transaction which was used to deploy the contract.
32
+
33
+ contract.**abi** => _Abi_
34
+
35
+ The ABI the contract was constructed with
36
+
37
+ ## Contract methods
38
+
39
+ contract.**deployed**() => _Promise < Contract >_
40
+
41
+ If the Contract object is the result of a ContractFactory deployment, this method will wait for the transaction to be resolved.
42
+
43
+ ## Meta-Class
44
+
45
+ A Meta-Class is a Class which has any of its properties determined at run-time. The Contract object uses a Contract's ABI to determine what methods are available, so the following sections describe the generic ways to interact with the properties added at run-time during the Contract constructor.
46
+
47
+ ### Read-Only Methods(constant)
48
+
49
+ A constant method (denoted view in Cairo) is read-only and evaluates a small amount of EVM code against the current blockchain state. It is therefore free and does not require any fee, but cannot make changes to the blockchain state...
50
+
51
+ contract.**METHOD_NAME**(...args [ , overrides ]) => _Promise < Result >_
52
+
53
+ The type of the result depends on the ABI. Result object will be returned with each parameter available positionally and if the parameter is named, it will also be available by its name.
54
+
55
+ The _overrides_ object for a read-only method may include any of:
56
+
57
+ - overrides.**blockIdentifier**
58
+
59
+ ### Write Methods (non-constant)
60
+
61
+ A non-constant method requires a transaction to be signed and requires payment in the form of a fee to be paid.
62
+
63
+ contract.**METHOD_NAME**(...args [ , overrides ]) => _Promise < AddTransactionResponse >_
64
+
65
+ Returns a AddTransactionResponse for the transaction after it is sent to the network. This requires the Contract has a signer.
66
+
67
+ The _overrides_ object for write methods may include any of:
68
+
69
+ - overrides.**signature** - Signature that will be used for the transaction
70
+ - overrides.**maxFee** - Max Fee for the transaction
71
+ - overrides.**nonce** - Nonce for the transaction
72
+
73
+ ### Write Methods Analysis
74
+
75
+ There are several options to analyze properties and results of a write method without actually executing it.
76
+
77
+ contract.estimateGas.**METHOD_NAME**( ...args ) => _Promise < EstimateFeeResponse >_
78
+
79
+ Returns the estimate units of gas that would be required to execute the METHOD_NAME with args and overrides.
80
+
81
+ contract.populateTransaction.**METHOD_NAME**( ...args [ , overrides ] ) ⇒ _Invocation_
82
+
83
+ Returns an _Invocation_ object which represents the transaction that would need to be signed and submitted to the network to execute METHOD_NAME with args and overrides.
84
+
85
+ The overrides are identical to the overrides above for write methods.
@@ -0,0 +1,42 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
5
+ # Contract Factory
6
+
7
+ Contract Factory allow you to deploy contracts onto StarkNet. To deploy a Contract, additional information is needed that is not available on a Contract object itself.
8
+
9
+ ## Creating an instance
10
+
11
+ `new starknet.ContractFactory( compiledContract , providerOrAccount, [ , abi ] )`
12
+
13
+ Creates a new instance of a ContractFactory for the contract described by the _compiledContract_.
14
+
15
+ `contractFacotry.connect(providerOrAccount)` _for changing the provider or account_
16
+
17
+ `contractFacotry.attach(address)` _for changing the address of the connected contract factory_
18
+
19
+ ## Properties
20
+
21
+ contractFactory.**abi** => _Abi_;
22
+
23
+ The ABI the contractFactory was constructed with
24
+
25
+ contractFactory.**compiledContract** => _CompiledContract_;
26
+
27
+ The compiled contract the contractFactory was constructed with
28
+
29
+ contractFactory.**providerOrAccount** => _Provider | Account_;
30
+
31
+ Provider or Account that are used to interact with the network
32
+
33
+ ## Methods
34
+
35
+ contractFactory.**attach**( address ) ⇒ _Contract_
36
+
37
+ Return an instance of a Contract attached to address. This is the same as using the Contract constructor with address and this _compiledContract_ and _providerOrAccount_ passed in when creating the ContractFactory.
38
+
39
+ contractFactory.deploy( constructorCalldata, addressSalt ) ⇒ Promise< Contract >
40
+ Uses the provider to deploy the Contract with constructorCalldata passed into the constructor and returns a Contract which is attached to the address where this contract will be deployed.
41
+
42
+ The transaction hash can be found at contract.deployTransactionHash, and no interactions should be made until the transaction is resolved.
@@ -1,4 +1,3 @@
1
1
  # StarkNet.js API
2
2
 
3
3
  This API is based on the <ins>[Starknet.js V3](https://github.com/0xs34n/starknet.js/discussions/102)</ins> Interface write up by <ins>[Janek](https://twitter.com/0xjanek)</ins> of <ins>[Argent](https://www.argent.xyz/)</ins>
4
-
@@ -6,5 +6,208 @@ sidebar_position: 1
6
6
 
7
7
  The **Provider** API allows you to interface with the StarkNet network, without signing transactions or messages.
8
8
 
9
- Typically, these are *read* calls on the blockchain.
9
+ Typically, these are _read_ calls on the blockchain.
10
10
 
11
+ ## Creating an instance
12
+
13
+ `new starknet.Provider(optionsOrProvider)`
14
+
15
+ The options for the provider depends from the network. The structure of the options object is:
16
+
17
+ - options.**baseUrl** - Base URL of the network
18
+ - options.**feederGatewayUrl** - Feeder Gateway Endpoint of the network
19
+ - options.**gatewayUrl** - Gateway Endpoint
20
+
21
+ Example:
22
+
23
+ ```
24
+ const provider = new starknet.Provider({
25
+ baseUrl: 'https://alpha4.starknet.io',
26
+ feederGatewayUrl: 'feeder_gateway',
27
+ gatewayUrl: 'gateway',
28
+ })
29
+ ```
30
+
31
+ **This is also default options for the constructor for the **testnet\*\*\*
32
+
33
+ ## Methods
34
+
35
+ Gets the smart contract address on the network
36
+
37
+ provider.**getContractAddresses**() => _Promise < GetContractAddressesResponse >_
38
+
39
+ ```
40
+ {
41
+ Starknet: string;
42
+ GpsStatementVerifier: string;
43
+ }
44
+ ```
45
+
46
+ <hr/>
47
+
48
+ provider.**callContract**(call [ , options ]) => _Promise < CallContractResponse >_
49
+
50
+ Calls a function on the StarkNet contract.
51
+
52
+ The call object structure:
53
+
54
+ - call.**contractAddress** - Address of the contract
55
+ - call.**entrypoint** - Entrypoint of the call (method name)
56
+ - call.**calldata** - Payload for the invoking the method
57
+
58
+ The options object structure:
59
+
60
+ - options.**blockIdentifier**
61
+
62
+ ###### CallContractResponse
63
+
64
+ ```
65
+ {
66
+ result: string[];
67
+ }
68
+ ```
69
+
70
+ <hr/>
71
+
72
+ provider.**getBlock**(blockIdentifire) => _Promise < GetBlockResponse >_
73
+
74
+ Gets the block information.
75
+
76
+ ###### _GetBlockResponse_
77
+
78
+ ```
79
+ {
80
+ block_hash: string;
81
+ parent_block_hash: string;
82
+ block_number: number;
83
+ state_root: string;
84
+ status: 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
85
+ transation: Transaction[];
86
+ timestamp: number;
87
+ transaction_receipts: [];
88
+ }
89
+ ```
90
+
91
+ <hr/>
92
+
93
+ provider.**getCode**(contractAddress, blockIdentifire) => _Promise < GetCodeResponse >_
94
+
95
+ Gets the code of the deployed contract.
96
+
97
+ ###### _GetCodeResponse_
98
+
99
+ ```
100
+ {
101
+ bytecode: string[];
102
+ abi: Abi;
103
+ }
104
+ ```
105
+
106
+ <hr/>
107
+
108
+ provider.**getStorageAt**(contractAddress, key, blockIdentifire) => _Promise < any >_
109
+
110
+ Gets the contract's storage variable at a specific key
111
+
112
+ <hr/>
113
+
114
+ provider.**getTransactionStatus**(txHash) => _Promise < GetTransactionStatusResponse >_
115
+
116
+ Gets the status of a transaction.
117
+
118
+ ###### _GetTransactionStatusResponse_
119
+
120
+ ```
121
+ {
122
+ tx_status: 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
123
+ block_hash: string;
124
+ tx_failure_reason?: {
125
+ tx_id: number;
126
+ code: string;
127
+ error_message: string;
128
+ }
129
+ }
130
+ ```
131
+
132
+ <hr/>
133
+
134
+ provider.**getTransactionReceipt**(txHash, txId) => _Promise < TransactionReceipt >_
135
+
136
+ Gets the status of a transaction.
137
+
138
+ ###### _TransactionReceipt_
139
+
140
+ ```
141
+ {
142
+ status: 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
143
+ transaction_hash: string;
144
+ transaction_index: number;
145
+ block_hash: string;
146
+ block_number: 'pending' | null | number;
147
+ l2_to_l1_messages: string[];
148
+ events: string[];
149
+ }
150
+ ```
151
+
152
+ <hr/>
153
+
154
+ provider.**getTransaction**(txHash) => _Promise < GetTransactionResponse >_
155
+
156
+ Gets the transaction information from a tx hash.
157
+
158
+ ###### _GetTransactionResponse_
159
+
160
+ ```
161
+ {
162
+ status: 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
163
+ transaction: Transaction;
164
+ block_hash: string;
165
+ block_number: 'pending' | null | number;
166
+ transaction_index: number;
167
+ transaction_hash: string;
168
+ }
169
+ ```
170
+
171
+ <hr/>
172
+
173
+ provider.**getTransactionTrace**(txHash) => _Promise < GetTransactionTraceResponse >_
174
+
175
+ Gets the transaction trace from a tx hash.
176
+
177
+ ###### _GetTransactionTraceResponse_
178
+
179
+ ```
180
+ {
181
+ function_invocation: {
182
+ caller_address: string;
183
+ contract_address: string;
184
+ code_address: string;
185
+ selector: string;
186
+ calldata: {
187
+ [inputName: string]: string | string[] | { type: 'struct'; [k: string]: BigNumberish };
188
+ };
189
+ result: Array<any>;
190
+ execution_resources: any;
191
+ internal_call: Array<any>;
192
+ events: Array<any>;
193
+ messages: Array<any>;
194
+ };
195
+ signature: Signature;
196
+ }
197
+ ```
198
+
199
+ <hr/>
200
+
201
+ provider.**deployContract**(payload [ , abi ]) => _Promise < AddTransactionResponse >_
202
+
203
+ Gets the transaction trace from a tx hash.
204
+
205
+ ###### _AddTransactionResponse_
206
+
207
+ ```
208
+ {
209
+ code: 'TRANSACTION_RECEIVED';
210
+ transaction_hash: string;
211
+ address?: string;
212
+ };
213
+ ```
@@ -6,3 +6,38 @@ sidebar_position: 3
6
6
 
7
7
  The **Signer** API allows you to sign transactions and messages, and also allows you to get the public key.
8
8
 
9
+ ## Creating an instance
10
+
11
+ `new starknet.Signer(keyPair)`
12
+
13
+ ## Signer Methods
14
+
15
+ signer.**getPubKey**() => _Promise < string >_
16
+
17
+ Returns public key of the signer
18
+
19
+ <hr />
20
+
21
+ signer.**signTransaction**(transactions, transactionsDetail [ , abi ]) => _Promise < Signature >_
22
+
23
+ Returns signature of the transaction
24
+
25
+ ###### Signature
26
+
27
+ ```
28
+ string[]
29
+ ```
30
+
31
+ <hr />
32
+
33
+ signer.**signMessage**(typedData, accountAddress) => _Promise < Signature >_
34
+
35
+ Returns signature of the transaction
36
+
37
+ ###### Signature
38
+
39
+ ```
40
+ string[]
41
+ ```
42
+
43
+ <hr />
@@ -41,8 +41,7 @@ const config = {
41
41
  blog: {
42
42
  showReadingTime: true,
43
43
  // Please change this to your repo.
44
- editUrl:
45
- 'https://github.com/0xs34n/starknet.js',
44
+ editUrl: 'https://github.com/0xs34n/starknet.js',
46
45
  },
47
46
  theme: {
48
47
  customCss: require.resolve('./src/css/custom.css'),
@@ -70,7 +69,7 @@ const config = {
70
69
  {
71
70
  position: 'left',
72
71
  label: 'Guides',
73
- to: '/guides/intro'
72
+ to: '/guides/intro',
74
73
  },
75
74
  // {to: '/blog', label: 'Blog', position: 'left'},
76
75
  {
@@ -17,7 +17,7 @@ import fs from "fs";
17
17
  import * as starknet from "starknet";
18
18
  ```
19
19
 
20
- ## Generate random key pair.
20
+ ## Generate random key pair.
21
21
 
22
22
  You can also get a key pair from a private key using `getKeyPair(pk: BigNumberish)`
23
23
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  sidebar_position: 3
3
3
  ---
4
+
4
5
  # Deploy an ERC20 Contract
5
6
 
6
7
  Dpeploy the contract and wait for deployment transaction to be accepted on StarkNet
@@ -15,13 +16,16 @@ const erc20Response = await defaultProvider.deployContract({
15
16
  console.log("Waiting for Tx to be Accepted on Starknet - ERC20 Deployment...");
16
17
  await defaultProvider.waitForTransaction(erc20Response.transaction_hash);
17
18
  ```
19
+
18
20
  ## Get the erc20 contract address and create the contact object
21
+
19
22
  ```javascript
20
23
  const erc20Address = erc20Response.address;
21
24
  const erc20 = new Contract(compiledErc20.abi, erc20Address);
22
25
  ```
23
26
 
24
27
  ## Mint tokens to an account address
28
+
25
29
  ```javascript
26
30
  const { transaction_hash: mintTxHash } = await erc20.mint(
27
31
  accountContract.address,
@@ -32,6 +36,7 @@ await defaultProvider.waitForTransaction(mintTxHash);
32
36
  ```
33
37
 
34
38
  ## Check balance after mint
39
+
35
40
  ```javascript
36
41
  console.log(`Calling StarkNet for accountContract balance...`);
37
42
  const balanceBeforeTransfer = await erc20.balance_of(accountContract.address);
@@ -43,6 +48,7 @@ console.log(
43
48
  ```
44
49
 
45
50
  ## Transfer tokens
51
+
46
52
  ```javascript
47
53
  // Get the nonce of the account and prepare transfer tx
48
54
  console.log(`Calling StarkNet for accountContract nonce...`);
@@ -76,6 +82,7 @@ await defaultProvider.waitForTransaction(transferTxHash);
76
82
  ```
77
83
 
78
84
  ## Check balance after transfer
85
+
79
86
  ```javascript
80
87
  // Check balance after transfer - should be 990
81
88
  console.log(`Calling StarkNet for accountContract balance...`);
@@ -17,4 +17,5 @@ npm install starknet@next
17
17
  Please check the StarkNet documentation <ins>[here](https://www.cairo-lang.org/docs/hello_starknet/intro.html)</ins> to compile starknet contracts.
18
18
 
19
19
  ## Full example with account & erc20
20
+
20
21
  Please see workshop <ins>[here](https://github.com/0xs34n/starknet.js-workshop)</ins>
package/www/sidebars.js CHANGED
@@ -14,7 +14,7 @@
14
14
  /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
15
15
  const sidebars = {
16
16
  // By default, Docusaurus generates a sidebar from the docs folder structure
17
- tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
17
+ tutorialSidebar: [{ type: 'autogenerated', dirName: '.' }],
18
18
 
19
19
  // But you can create a sidebar manually
20
20
  /*