Skip to content

Commit

Permalink
docs: bump ArgentX account to v0.4.0 (#1167)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeR26 committed Aug 20, 2024
1 parent da20310 commit 53d8e14
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions www/docs/guides/create_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,21 @@ console.log('✅ New OpenZeppelin account created.\n address =', contract_addr

## Create an Argent account

Here, we will create a wallet with the Argent smart contract v0.3.0. The contract class is already implemented in the networks.
Here, we will create a wallet with the Argent smart contract v0.4.0. The contract class is already implemented in the networks.

```typescript
import { Account, ec, json, stark, RpcProvider, hash, CallData } from 'starknet';
import {
Account,
ec,
json,
stark,
RpcProvider,
hash,
CallData,
CairoOption,
CairoOptionVariant,
CairoCustomEnum,
} from 'starknet';
```

### Compute address
Expand All @@ -99,8 +110,9 @@ import { Account, ec, json, stark, RpcProvider, hash, CallData } from 'starknet'
// connect provider
const provider = new RpcProvider({ nodeUrl: `${myNodeUrl}` });

//new Argent X account v0.3.0
const argentXaccountClassHash = '0x1a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003';
//new Argent X account v0.4.0
const argentXaccountClassHash =
'0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f';

// Generate public and private key pair.
const privateKeyAX = stark.randomAddress();
Expand All @@ -109,9 +121,11 @@ const starkKeyPubAX = ec.starkCurve.getStarkKey(privateKeyAX);
console.log('AX_ACCOUNT_PUBLIC_KEY=', starkKeyPubAX);

// Calculate future address of the ArgentX account
const axSigner = new CairoCustomEnum({ Starknet: { pubkey: starkKeyPubAX } });
const axGuardian = new CairoOption<unknown>(CairoOptionVariant.None);
const AXConstructorCallData = CallData.compile({
owner: starkKeyPubAX,
guardian: '0',
owner: axSigner,
guardian: axGuardian,
});
const AXcontractAddress = hash.calculateContractAddressFromHash(
starkKeyPubAX,
Expand All @@ -122,7 +136,7 @@ const AXcontractAddress = hash.calculateContractAddressFromHash(
console.log('Precalculated account address=', AXcontractAddress);
```

If you want a specific private key, replace `stark.randomAddress`()` with your choice.
If you want a specific private key, replace `stark.randomAddress()` with a value of your choice.

Then you have to fund this address.

Expand Down

0 comments on commit 53d8e14

Please sign in to comment.