starknet 4.9.0 → 4.10.0

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +1 -3
  3. package/__tests__/account.test.ts +1 -1
  4. package/__tests__/defaultProvider.test.ts +85 -210
  5. package/__tests__/fixtures.ts +1 -1
  6. package/__tests__/rpcProvider.test.ts +4 -3
  7. package/__tests__/udc.test.ts +41 -0
  8. package/account/default.d.ts +3 -1
  9. package/account/default.js +50 -0
  10. package/account/interface.d.ts +24 -7
  11. package/constants.d.ts +7 -1
  12. package/constants.js +7 -1
  13. package/contract/default.d.ts +11 -27
  14. package/contract/default.js +104 -120
  15. package/contract/interface.d.ts +5 -2
  16. package/dist/account/default.d.ts +3 -1
  17. package/dist/account/default.js +50 -0
  18. package/dist/account/interface.d.ts +24 -7
  19. package/dist/constants.d.ts +7 -1
  20. package/dist/constants.js +7 -1
  21. package/dist/contract/default.d.ts +11 -27
  22. package/dist/contract/default.js +104 -120
  23. package/dist/contract/interface.d.ts +5 -2
  24. package/dist/provider/rpc.d.ts +3 -1
  25. package/dist/provider/rpc.js +15 -2
  26. package/dist/provider/sequencer.d.ts +4 -2
  27. package/dist/provider/sequencer.js +18 -5
  28. package/dist/signer/default.d.ts +2 -2
  29. package/dist/signer/default.js +15 -15
  30. package/dist/signer/interface.d.ts +2 -0
  31. package/dist/types/api/index.d.ts +0 -6
  32. package/dist/types/index.d.ts +1 -1
  33. package/dist/types/lib.d.ts +13 -0
  34. package/dist/utils/number.d.ts +1 -0
  35. package/dist/utils/number.js +3 -1
  36. package/package.json +1 -1
  37. package/provider/rpc.d.ts +3 -1
  38. package/provider/rpc.js +15 -2
  39. package/provider/sequencer.d.ts +4 -2
  40. package/provider/sequencer.js +18 -5
  41. package/signer/default.d.ts +2 -2
  42. package/signer/default.js +15 -15
  43. package/signer/interface.d.ts +2 -0
  44. package/src/account/default.ts +43 -3
  45. package/src/account/interface.ts +34 -7
  46. package/src/constants.ts +7 -0
  47. package/src/contract/default.ts +123 -140
  48. package/src/contract/interface.ts +5 -2
  49. package/src/provider/rpc.ts +7 -3
  50. package/src/provider/sequencer.ts +13 -4
  51. package/src/signer/default.ts +18 -18
  52. package/src/signer/interface.ts +2 -0
  53. package/src/types/api/index.ts +0 -4
  54. package/src/types/index.ts +1 -1
  55. package/src/types/lib.ts +13 -0
  56. package/src/utils/number.ts +2 -0
  57. package/types/api/index.d.ts +0 -6
  58. package/types/index.d.ts +1 -1
  59. package/types/lib.d.ts +13 -0
  60. package/utils/number.d.ts +1 -0
  61. package/utils/number.js +3 -1
  62. package/www/docs/API/account.md +122 -22
  63. package/www/docs/API/contract.md +39 -3
  64. package/www/docs/API/provider.md +4 -0
  65. package/www/docs/API/signer.md +56 -2
@@ -57,6 +57,7 @@ export abstract class ContractInterface {
57
57
  *
58
58
  * @param method name of the method
59
59
  * @param args Array of the arguments for the call
60
+ * @param options optional blockIdentifier
60
61
  * @returns Result of the call as an array with key value pars
61
62
  */
62
63
  public abstract call(
@@ -72,6 +73,7 @@ export abstract class ContractInterface {
72
73
  *
73
74
  * @param method name of the method
74
75
  * @param args Array of the arguments for the invoke
76
+ * @param options
75
77
  * @returns Add Transaction Response
76
78
  */
77
79
  public abstract invoke(
@@ -81,10 +83,11 @@ export abstract class ContractInterface {
81
83
  ): Promise<InvokeFunctionResponse>;
82
84
 
83
85
  /**
84
- * Calls a method on a contract
86
+ * Estimates a method on a contract
85
87
  *
86
88
  * @param method name of the method
87
89
  * @param args Array of the arguments for the call
90
+ * @param options optional blockIdentifier
88
91
  */
89
92
  public abstract estimate(
90
93
  method: string,
@@ -99,7 +102,7 @@ export abstract class ContractInterface {
99
102
  *
100
103
  * @param method name of the method
101
104
  * @param args Array of the arguments for the call
102
- * @returns Invocation objet
105
+ * @returns Invocation object
103
106
  */
104
107
  public abstract populate(method: string, args?: Array<any>): Invocation;
105
108
  }
@@ -38,6 +38,7 @@ import { Block, BlockIdentifier } from './utils';
38
38
  export type RpcProviderOptions = {
39
39
  nodeUrl: string;
40
40
  retries?: number;
41
+ headers?: object;
41
42
  };
42
43
 
43
44
  export class RpcProvider implements ProviderInterface {
@@ -46,14 +47,17 @@ export class RpcProvider implements ProviderInterface {
46
47
  // from interface
47
48
  public chainId!: StarknetChainId;
48
49
 
50
+ public headers: object;
51
+
49
52
  private responseParser = new RPCResponseParser();
50
53
 
51
54
  private retries: number;
52
55
 
53
56
  constructor(optionsOrProvider: RpcProviderOptions) {
54
- const { nodeUrl, retries } = optionsOrProvider;
57
+ const { nodeUrl, retries, headers } = optionsOrProvider;
55
58
  this.nodeUrl = nodeUrl;
56
59
  this.retries = retries || 200;
60
+ this.headers = { 'Content-Type': 'application/json', ...headers };
57
61
 
58
62
  this.getChainId().then((chainId) => {
59
63
  this.chainId = chainId;
@@ -64,7 +68,7 @@ export class RpcProvider implements ProviderInterface {
64
68
  return fetch(this.nodeUrl, {
65
69
  method: 'POST',
66
70
  body: stringify({ method, jsonrpc: '2.0', params, id: 0 }),
67
- headers: { 'Content-Type': 'application/json' },
71
+ headers: this.headers,
68
72
  });
69
73
  }
70
74
 
@@ -196,7 +200,7 @@ export class RpcProvider implements ProviderInterface {
196
200
 
197
201
  public async getClassAt(
198
202
  contractAddress: string,
199
- blockIdentifier: BlockIdentifier
203
+ blockIdentifier: BlockIdentifier = 'pending'
200
204
  ): Promise<RPC.ContractClass> {
201
205
  const block_id = new Block(blockIdentifier).identifier;
202
206
  return this.fetchEndpoint('starknet_getClassAt', {
@@ -44,7 +44,7 @@ import { GatewayError, HttpError } from './errors';
44
44
  import { ProviderInterface } from './interface';
45
45
  import { Block, BlockIdentifier } from './utils';
46
46
 
47
- type NetworkName = 'mainnet-alpha' | 'goerli-alpha';
47
+ type NetworkName = 'mainnet-alpha' | 'goerli-alpha' | 'goerli-alpha-2';
48
48
 
49
49
  function isEmptyQueryObject(obj?: Record<any, any>): obj is undefined {
50
50
  return (
@@ -62,6 +62,7 @@ export type SequencerProviderOptions =
62
62
  feederGatewayUrl?: string;
63
63
  gatewayUrl?: string;
64
64
  chainId?: StarknetChainId;
65
+ headers?: object;
65
66
  };
66
67
 
67
68
  export class SequencerProvider implements ProviderInterface {
@@ -73,9 +74,11 @@ export class SequencerProvider implements ProviderInterface {
73
74
 
74
75
  public chainId: StarknetChainId;
75
76
 
77
+ public headers: object | undefined;
78
+
76
79
  private responseParser = new SequencerAPIResponseParser();
77
80
 
78
- constructor(optionsOrProvider: SequencerProviderOptions = { network: 'goerli-alpha' }) {
81
+ constructor(optionsOrProvider: SequencerProviderOptions = { network: 'goerli-alpha-2' }) {
79
82
  if ('network' in optionsOrProvider) {
80
83
  this.baseUrl = SequencerProvider.getNetworkFromName(optionsOrProvider.network);
81
84
  this.chainId = SequencerProvider.getChainIdFromBaseUrl(this.baseUrl);
@@ -93,6 +96,8 @@ export class SequencerProvider implements ProviderInterface {
93
96
  this.chainId =
94
97
  optionsOrProvider.chainId ??
95
98
  SequencerProvider.getChainIdFromBaseUrl(optionsOrProvider.baseUrl);
99
+
100
+ this.headers = optionsOrProvider?.headers;
96
101
  }
97
102
  }
98
103
 
@@ -101,6 +106,9 @@ export class SequencerProvider implements ProviderInterface {
101
106
  case 'mainnet-alpha':
102
107
  return 'https://alpha-mainnet.starknet.io';
103
108
  case 'goerli-alpha':
109
+ return 'https://alpha4.starknet.io';
110
+ case 'goerli-alpha-2':
111
+ return 'https://alpha4-2.starknet.io';
104
112
  default:
105
113
  return 'https://alpha4.starknet.io';
106
114
  }
@@ -153,13 +161,14 @@ export class SequencerProvider implements ProviderInterface {
153
161
  return `?${queryString}`;
154
162
  }
155
163
 
156
- private getHeaders(method: 'POST' | 'GET'): Record<string, string> | undefined {
164
+ private getHeaders(method: 'POST' | 'GET'): object | undefined {
157
165
  if (method === 'POST') {
158
166
  return {
159
167
  'Content-Type': 'application/json',
168
+ ...this.headers,
160
169
  };
161
170
  }
162
- return undefined;
171
+ return this.headers;
163
172
  }
164
173
 
165
174
  // typesafe fetch
@@ -28,6 +28,11 @@ export class Signer implements SignerInterface {
28
28
  return getStarkKey(this.keyPair);
29
29
  }
30
30
 
31
+ public async signMessage(typedData: TypedData, accountAddress: string): Promise<Signature> {
32
+ const msgHash = getMessageHash(typedData, accountAddress);
33
+ return sign(this.keyPair, msgHash);
34
+ }
35
+
31
36
  public async signTransaction(
32
37
  transactions: Call[],
33
38
  transactionsDetail: InvocationsSignerDetails,
@@ -52,22 +57,6 @@ export class Signer implements SignerInterface {
52
57
  return sign(this.keyPair, msgHash);
53
58
  }
54
59
 
55
- public async signDeclareTransaction(
56
- // contractClass: ContractClass, // Should be used once class hash is present in ContractClass
57
- { classHash, senderAddress, chainId, maxFee, version, nonce }: DeclareSignerDetails
58
- ) {
59
- const msgHash = calculateDeclareTransactionHash(
60
- classHash,
61
- senderAddress,
62
- version,
63
- maxFee,
64
- chainId,
65
- nonce
66
- );
67
-
68
- return sign(this.keyPair, msgHash);
69
- }
70
-
71
60
  public async signDeployAccountTransaction({
72
61
  classHash,
73
62
  contractAddress,
@@ -92,8 +81,19 @@ export class Signer implements SignerInterface {
92
81
  return sign(this.keyPair, msgHash);
93
82
  }
94
83
 
95
- public async signMessage(typedData: TypedData, accountAddress: string): Promise<Signature> {
96
- const msgHash = getMessageHash(typedData, accountAddress);
84
+ public async signDeclareTransaction(
85
+ // contractClass: ContractClass, // Should be used once class hash is present in ContractClass
86
+ { classHash, senderAddress, chainId, maxFee, version, nonce }: DeclareSignerDetails
87
+ ) {
88
+ const msgHash = calculateDeclareTransactionHash(
89
+ classHash,
90
+ senderAddress,
91
+ version,
92
+ maxFee,
93
+ chainId,
94
+ nonce
95
+ );
96
+
97
97
  return sign(this.keyPair, msgHash);
98
98
  }
99
99
  }
@@ -40,6 +40,7 @@ export abstract class SignerInterface {
40
40
 
41
41
  /**
42
42
  * Signs a DEPLOY_ACCOUNT transaction with the starknet private key and returns the signature
43
+ *
43
44
  * @param transaction
44
45
  * - contractAddress - the computed address of the contract
45
46
  * - constructorCalldata - calldata to be passed in deploy constructor
@@ -56,6 +57,7 @@ export abstract class SignerInterface {
56
57
 
57
58
  /**
58
59
  * Signs a DECLARE transaction with the starknet private key and returns the signature
60
+ *
59
61
  * @param transaction
60
62
  * - classHash - computed class hash. Will be replaced by ContractClass in future once class hash is present in CompiledContract
61
63
  * - senderAddress - the address of the sender
@@ -1,10 +1,6 @@
1
1
  import { BigNumberish } from '../../utils/number';
2
2
  import { Signature } from '../lib';
3
3
 
4
- export type RawArgs = {
5
- [inputName: string]: string | string[] | { type: 'struct'; [k: string]: BigNumberish };
6
- };
7
-
8
4
  export type Calldata = string[];
9
5
 
10
6
  export type Overrides = {
@@ -1,6 +1,6 @@
1
1
  export * from './lib';
2
2
  export * as api from './api';
3
- export { Calldata, Overrides, RawArgs } from './api';
3
+ export { Calldata, Overrides } from './api';
4
4
  export * from './signer';
5
5
  export * from './contract';
6
6
  export * from './account';
package/src/types/lib.ts CHANGED
@@ -7,6 +7,11 @@ export type KeyPair = EC.KeyPair;
7
7
  export type Signature = string[];
8
8
  export type RawCalldata = BigNumberish[];
9
9
  export type AllowArray<T> = T | T[];
10
+ export type RawArgs =
11
+ | {
12
+ [inputName: string]: string | string[] | { type: 'struct'; [k: string]: BigNumberish };
13
+ }
14
+ | string[];
10
15
 
11
16
  export interface ContractClass {
12
17
  program: CompressedProgram;
@@ -14,6 +19,14 @@ export interface ContractClass {
14
19
  abi?: Abi;
15
20
  }
16
21
 
22
+ export type UniversalDeployerContractPayload = {
23
+ classHash: BigNumberish;
24
+ salt: string;
25
+ unique: boolean;
26
+ constructorCalldata?: RawArgs;
27
+ isDevnet?: boolean;
28
+ };
29
+
17
30
  export type DeployContractPayload = {
18
31
  contract: CompiledContract | string;
19
32
  constructorCalldata?: RawCalldata;
@@ -88,3 +88,5 @@ export function getHexString(value: string) {
88
88
  export function getHexStringArray(value: Array<string>) {
89
89
  return value.map((el) => getHexString(el));
90
90
  }
91
+
92
+ export const toCairoBool = (value: boolean): string => (+value).toString();
@@ -1,11 +1,5 @@
1
1
  import { BigNumberish } from '../../utils/number';
2
2
  import { Signature } from '../lib';
3
- export declare type RawArgs = {
4
- [inputName: string]: string | string[] | {
5
- type: 'struct';
6
- [k: string]: BigNumberish;
7
- };
8
- };
9
3
  export declare type Calldata = string[];
10
4
  export declare type Overrides = {
11
5
  maxFee?: BigNumberish;
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './lib';
2
2
  export * as api from './api';
3
- export { Calldata, Overrides, RawArgs } from './api';
3
+ export { Calldata, Overrides } from './api';
4
4
  export * from './signer';
5
5
  export * from './contract';
6
6
  export * from './account';
package/types/lib.d.ts CHANGED
@@ -5,11 +5,24 @@ export declare type KeyPair = EC.KeyPair;
5
5
  export declare type Signature = string[];
6
6
  export declare type RawCalldata = BigNumberish[];
7
7
  export declare type AllowArray<T> = T | T[];
8
+ export declare type RawArgs = {
9
+ [inputName: string]: string | string[] | {
10
+ type: 'struct';
11
+ [k: string]: BigNumberish;
12
+ };
13
+ } | string[];
8
14
  export interface ContractClass {
9
15
  program: CompressedProgram;
10
16
  entry_points_by_type: RPC.ContractClass['entry_points_by_type'];
11
17
  abi?: Abi;
12
18
  }
19
+ export declare type UniversalDeployerContractPayload = {
20
+ classHash: BigNumberish;
21
+ salt: string;
22
+ unique: boolean;
23
+ constructorCalldata?: RawArgs;
24
+ isDevnet?: boolean;
25
+ };
13
26
  export declare type DeployContractPayload = {
14
27
  contract: CompiledContract | string;
15
28
  constructorCalldata?: RawCalldata;
package/utils/number.d.ts CHANGED
@@ -13,3 +13,4 @@ export declare const toHexString: (value: string) => string;
13
13
  export declare function getDecimalString(value: string): string;
14
14
  export declare function getHexString(value: string): string;
15
15
  export declare function getHexStringArray(value: Array<string>): string[];
16
+ export declare const toCairoBool: (value: boolean) => string;
package/utils/number.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getHexStringArray = exports.getHexString = exports.getDecimalString = exports.toHexString = exports.isStringWholeNumber = exports.bigNumberishArrayToHexadecimalStringArray = exports.bigNumberishArrayToDecimalStringArray = exports.assertInRange = exports.toFelt = exports.hexToDecimalString = exports.toHex = exports.toBN = exports.isHex = void 0;
29
+ exports.toCairoBool = exports.getHexStringArray = exports.getHexString = exports.getDecimalString = exports.toHexString = exports.isStringWholeNumber = exports.bigNumberishArrayToHexadecimalStringArray = exports.bigNumberishArrayToDecimalStringArray = exports.assertInRange = exports.toFelt = exports.hexToDecimalString = exports.toHex = exports.toBN = exports.isHex = void 0;
30
30
  var bn_js_1 = __importStar(require("bn.js"));
31
31
  var minimalistic_assert_1 = __importDefault(require("minimalistic-assert"));
32
32
  var encode_1 = require("./encode");
@@ -108,3 +108,5 @@ function getHexStringArray(value) {
108
108
  return value.map(function (el) { return getHexString(el); });
109
109
  }
110
110
  exports.getHexStringArray = getHexStringArray;
111
+ var toCairoBool = function (value) { return (+value).toString(); };
112
+ exports.toCairoBool = toCairoBool;
@@ -24,20 +24,56 @@ The address of the account contract.
24
24
 
25
25
  ## Methods
26
26
 
27
- account.**getNonce()** => _Promise < BigNumberish >_
27
+ account.**getNonce(blockIdentifier)** => _Promise < BigNumberish >_
28
28
 
29
- Gets the new Nonce of the connected account for the next transaction.
29
+ Gets the nonce of the account with respect to a specific block.
30
+
31
+ _blockIdentifier_ - optional blockIdentifier. Defaults to 'pending'.
32
+
33
+ Returns the nonce of the account.
34
+
35
+ <hr />
36
+
37
+ account.**estimateInvokeFee**(calls [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
38
+
39
+ Estimate Fee for executing an INVOKE transaction on starknet.
40
+
41
+ The _calls_ object structure:
42
+
43
+ - calls.**contractAddress** - Address of the contract
44
+ - calls.**entrypoint** - Entrypoint of the call (method name)
45
+ - calls.**calldata** - Payload for the invoking method
46
+
47
+ The _estimateFeeDetails_ object may include any of:
48
+
49
+ - estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
50
+ - estimateFeeDetails.**nonce** - Nonce for the transaction
51
+
52
+ ###### _EstimateFeeResponse_
53
+
54
+ ```typescript
55
+ {
56
+ overall_fee: BN;
57
+ gas_consumed?: BN;
58
+ gas_price?: BN;
59
+ }
60
+ ```
30
61
 
31
62
  <hr />
32
63
 
33
- account.**estimateInvokeFee**(calls [ , options ]) => _Promise < EstimateFeeResponse >_
64
+ account.**estimateDeclareFee**(contractPayload [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
65
+
66
+ Estimate Fee for executing a DECLARE transaction on starknet.
34
67
 
35
- Gets the estimated fee for the call(s).
68
+ The _contractPayload_ object structure:
36
69
 
37
- The _options_ object may include any of:
70
+ - contractPayload.**contract** - The compiled contract
71
+ - contractPayload.**classHash** - This can be obtained by using starknet-cli. Once the classHash is included in CompiledContract, this can be removed
38
72
 
39
- - options.**blockIdentifier** - Block Identifier for the transaction
40
- - options.**nonce** - Nonce for the transaction
73
+ The _estimateFeeDetails_ object may include any of:
74
+
75
+ - estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
76
+ - estimateFeeDetails.**nonce** - Nonce for the transaction
41
77
 
42
78
  ###### _EstimateFeeResponse_
43
79
 
@@ -51,14 +87,19 @@ The _options_ object may include any of:
51
87
 
52
88
  <hr />
53
89
 
54
- account.**estimateDeclareFee**(contractPayload [ , options ]) => _Promise < EstimateFeeResponse >_
90
+ account.**estimateAccountDeployFee**(contractPayload [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
91
+
92
+ Estimate Fee for executing a DEPLOY_ACCOUNT transaction on starknet
55
93
 
56
- Gets the estimated fee for the declare transaction.
94
+ The _contractPayload_ object structure:
57
95
 
58
- The _options_ object may include any of:
96
+ - contractPayload.**contract** - The compiled contract to be declared
97
+ - contractPayload.**classHash** - This can be obtained by using starknet-cli. Once the classHash is included in CompiledContract, this can be removed
59
98
 
60
- - options.**blockIdentifier** - Block Identifier for the transaction
61
- - options.**nonce** - Nonce for the transaction
99
+ The _estimateFeeDetails_ object may include any of:
100
+
101
+ - estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
102
+ - estimateFeeDetails.**nonce** - Nonce for the transaction
62
103
 
63
104
  ###### _EstimateFeeResponse_
64
105
 
@@ -72,17 +113,26 @@ The _options_ object may include any of:
72
113
 
73
114
  <hr />
74
115
 
75
- account.**execute**(calls [ , abi , transactionsDetail ]) => _Promise < AddTransactionResponse >_
116
+ account.**execute**(transactions [ , abi , transactionsDetail ]) => _Promise < InvokeFunctionResponse >_
76
117
 
77
118
  Executes one or multiple calls using the account contract.
78
119
 
120
+ The _transactions_ object structure:
121
+
122
+ - contractPayload.**contractAddress** - the address of the contract
123
+ - contractPayload.**entrypoint** - the entrypoint of the contract
124
+ - contractPayload.**calldata** - (defaults to []) the calldata
125
+ - contractPayload.**signature** - (defaults to []) the signature
126
+
127
+ _abi_ - (optional) the abi of the contract for better displaying
128
+
79
129
  The _transactionsDetail_ object may include any of:
80
130
 
81
131
  - transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
82
132
  - transactionsDetail.**nonce** - Nonce for the transaction
83
133
  - transactionsDetail.**version** - Version for the transaction (default is 1)
84
134
 
85
- ###### _AddTransactionResponse_
135
+ ###### _InvokeFunctionResponse_
86
136
 
87
137
  ```typescript
88
138
  {
@@ -92,12 +142,14 @@ The _transactionsDetail_ object may include any of:
92
142
 
93
143
  <hr />
94
144
 
95
- account.**declare**(payload [ , transactionsDetail ]) => _Promise < DeclareContractResponse >_
145
+ account.**declare**(contractPayload [ , transactionsDetail ]) => _Promise < DeclareContractResponse >_
96
146
 
97
- The _payload_ object consists of:
147
+ Declares a given compiled contract (json) to starknet.
98
148
 
99
- - payload.**contract** - The compiled contract
100
- - payload.**classHash** - Hash of the compiled contract
149
+ The _contractPayload_ object consists of:
150
+
151
+ - contractPayload.**contract** - The compiled contract
152
+ - contractPayload.**classHash** - Hash of the compiled contract
101
153
 
102
154
  The _transactionsDetail_ object may include any of:
103
155
 
@@ -105,8 +157,6 @@ The _transactionsDetail_ object may include any of:
105
157
  - transactionsDetail.**nonce** - Nonce for the transaction
106
158
  - transactionsDetail.**version** - Version for the transaction (default is 1)
107
159
 
108
- Declares a contract on Starknet.
109
-
110
160
  > _Note:_ Once the classHash is included in CompiledContract, this parameter can be removed. Currently it can be pre-computed from starknet-cli.
111
161
 
112
162
  Example:
@@ -128,11 +178,43 @@ const declareTx = await account.declare({
128
178
  };
129
179
  ```
130
180
 
181
+ <hr />
182
+
183
+ account.**deployAccount**(contractPayload [ , transactionsDetail ]) => _Promise < DeployContractResponse >_
184
+
185
+ Declares a given compiled contract (json) to starknet.
186
+
187
+ The _contractPayload_ object consists of:
188
+
189
+ - contractPayload.**classHash** - Hash of the compiled contract
190
+ - contractPayload.**constructorCalldata** - optional
191
+ - contractPayload.**addressSalt** - optional
192
+ - contractPayload.**contractAddress** - optional
193
+
194
+ The _transactionsDetail_ object may include any of:
195
+
196
+ - transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
197
+ - transactionsDetail.**nonce** - Nonce for the transaction
198
+ - transactionsDetail.**version** - Version for the transaction (default is 1)
199
+
200
+ > _Note:_ Once the classHash is included in CompiledContract, this parameter can be removed. Currently it can be pre-computed from starknet-cli.
201
+
202
+ ###### _DeployContractResponse_
203
+
204
+ ```typescript
205
+ {
206
+ contract_address: string;
207
+ transaction_hash: string;
208
+ };
209
+ ```
210
+
131
211
  <hr/>
132
212
 
133
213
  account.**signMessage**(typedData) => _Promise < Signature >_
134
214
 
135
- Creates a signature from the passed data.
215
+ Sign an JSON object for off-chain usage with the starknet private key and return the signature. This adds a message prefix so it cant be interchanged with transactions.
216
+
217
+ _typedData_ - JSON object to be signed
136
218
 
137
219
  ###### _Signature_
138
220
 
@@ -144,7 +226,11 @@ string[];
144
226
 
145
227
  account.**hashMessage**(typedData) => _Promise < string >_
146
228
 
147
- Creates a hash from the passed data.
229
+ Hash a JSON object with pederson hash and return the hash. This adds a message prefix so it cant be interchanged with transactions.
230
+
231
+ _typedData_ - JSON object to be signed
232
+
233
+ Returns the hash of the JSON object.
148
234
 
149
235
  <hr />
150
236
 
@@ -162,4 +248,18 @@ account.**verifyMessage**(typedData, signature) => _Promise < boolean >_
162
248
 
163
249
  Verify a signature of a JSON object.
164
250
 
251
+ _typedData_ - JSON object to be verified
252
+ _signature_ - signature of the JSON object
253
+
254
+ Returns true if the signature is valid, false otherwise
255
+
165
256
  <hr />
257
+
258
+ account.**getSuggestedMaxFee**(estimateFeeAction, details) => _Promise < BigNumberish >_
259
+
260
+ Gets Suggested Max Fee based on the transaction type.
261
+
262
+ The _details_ object may include any of:
263
+
264
+ - details.**blockIdentifier**
265
+ - details.**nonce**
@@ -18,6 +18,10 @@ Contracts allow you to transform Cairo values, like `Uint256` to `BigNumber`. It
18
18
 
19
19
  ## Properties
20
20
 
21
+ contract.**abi** => _Abi_
22
+
23
+ The ABI the contract was constructed with.
24
+
21
25
  contract.**address** => _string_
22
26
 
23
27
  The address the contract was constructed/connected with.
@@ -30,16 +34,48 @@ contract.**deployTransactionHash** => _string | null_
30
34
 
31
35
  If the Contract object is the result of a ContractFactory deployment, this is the transaction which was used to deploy the contract.
32
36
 
33
- contract.**abi** => _Abi_
37
+ ## Methods
34
38
 
35
- The ABI the contract was constructed with.
39
+ contract.**attach**(address) => void
36
40
 
37
- ## Methods
41
+ Saves the address of the contract deployed on network that will be used for interaction.
42
+
43
+ _address_ - address of the contract.
44
+
45
+ <br></br>
46
+
47
+ contract.**connect**(providerOrAccount) => void
48
+
49
+ Attaches to new Provider or Account
50
+
51
+ <br></br>
38
52
 
39
53
  contract.**deployed**() => _Promise < Contract >_
40
54
 
41
55
  If the Contract object is the result of a ContractFactory deployment, this method will wait for the transaction to be resolved.
42
56
 
57
+ <br></br>
58
+
59
+ contract.**call**(method, args, options) => _Promise < Result >_
60
+
61
+ Calls a method on a contract.
62
+
63
+ <br></br>
64
+
65
+ contract.**invoke**(method, args, options) => _Promise < InvokeFunctionResponse >_
66
+
67
+ Invokes a method on a contract.
68
+
69
+ <br></br>
70
+
71
+ contract.**estimate**(method, args, options) => _Promise < any >_
72
+
73
+ Estimates a method on a contract.
74
+
75
+ <br></br>
76
+
77
+ contract.**populate**(method, args, options) => _Invocation_
78
+
43
79
  ## Meta-Class
44
80
 
45
81
  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.
@@ -259,10 +259,12 @@ The options for the provider depend on the network. The structure of the options
259
259
  - options.**baseUrl** - Base URL of the network
260
260
  - options.**feederGatewayUrl** - Feeder Gateway Endpoint of the network
261
261
  - options.**gatewayUrl** - Gateway Endpoint
262
+ - options.**headers** - [Optional] custom fetch headers
262
263
 
263
264
  or
264
265
 
265
266
  - options.**network** - Either 'mainnet-alpha' or 'goerli-alpha'
267
+ - options.**headers** - [Optional] custom fetch headers
266
268
 
267
269
  Example:
268
270
 
@@ -396,6 +398,8 @@ Gets the transaction trace from a tx hash.
396
398
  `new starknet.RpcProvider(options)`
397
399
 
398
400
  - options.**nodeUrl** - Starknet RPC node url
401
+ - options.**headers** - [Optional] custom fetch headers
402
+ - options.**retries** - [Optional] wait for transaction max retries
399
403
 
400
404
  Example:
401
405