Skip to content

Commit

Permalink
feat: update account guide
Browse files Browse the repository at this point in the history
  • Loading branch information
badurinantun committed Jun 1, 2022
1 parent cd61356 commit b5275b3
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions www/guides/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ Install the latest version of starknet with `npm install starknet@next`

```javascript
import fs from "fs";
import * as starknet from "starknet";
import fs from "fs";
import {
Account,
Contract,
defaultProvider,
ec,
json,
} from "starknet";
```

## Generate random key pair.
Expand Down Expand Up @@ -44,17 +51,23 @@ const accountResponse = await defaultProvider.deployContract({

Wait for the deployment transaction to be accepted and assign the address of the deployed account to the Account object.

Use your new account object to sign transactions, messages or verify signatures!

```javascript
await defaultProvider.waitForTransaction(accountResponse.transaction_hash);
const accountContract = new Contract(
compiledArgentAccount.abi,
accountResponse.address
);
const { transaction_hash: initializeTxHash } = await accountContract.initialize(
starkKeyPub,
"0"
const initializeResponse = await accountContract.initialize(starkKeyPub, "0");

await defaultProvider.waitForTransaction(initializeResponse.transaction_hash);
```

Once account contract is initialized [Account](../docs/API/account.md) instance can be created. Use your new account instance to sign transactions, messages or verify signatures!

```js
const account = new Account(
defaultProvider,
accountResponse.address,
starkKeyPair
);
await defaultProvider.waitForTransaction(initializeTxHash);
```

0 comments on commit b5275b3

Please sign in to comment.