Skip to content

Commit

Permalink
docs: small guides cleanup (#1048)
Browse files Browse the repository at this point in the history
* docs: fix nodeUrl code typo (#1046)

* docs: small guides cleanup

---------

Co-authored-by: Joel Mun <hj923@hotmail.com>
  • Loading branch information
ivpavici and 9oelM committed Mar 28, 2024
1 parent 5265995 commit f121a75
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
7 changes: 4 additions & 3 deletions www/docs/guides/connect_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ As a consequence of account abstraction, you can find accounts that uses Ethereu
To connect to this type of account:

```typescript
const myEthPrivateKey = "0x525bc68475c0955fae83869beec0996114d4bb27b28b781ed2a20ef23121b8de";
const myEthAccountAddressInStarknet = "0x65a822fbee1ae79e898688b5a4282dc79e0042cbed12f6169937fddb4c26641";
const myEthPrivateKey = '0x525bc68475c0955fae83869beec0996114d4bb27b28b781ed2a20ef23121b8de';
const myEthAccountAddressInStarknet =
'0x65a822fbee1ae79e898688b5a4282dc79e0042cbed12f6169937fddb4c26641';
const myEthSigner = new EthSigner(myEthPrivateKey);
const myEthAccount = new Account(provider, myEthAccountAddressInStarknet, myEthSigner)
const myEthAccount = new Account(provider, myEthAccountAddressInStarknet, myEthSigner);
```

And if you need a random Ethereum private key:
Expand Down
18 changes: 10 additions & 8 deletions www/docs/guides/create_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This contract is coded in Cairo 1.
import { Account, constants, ec, json, stark, RpcProvider, hash, CallData } from 'starknet';
```

### compute address
### Compute address

```typescript
// connect provider (Mainnet or Sepolia)
Expand Down Expand Up @@ -66,7 +66,7 @@ curl -X POST http://127.0.0.1:5050/mint -d '{"address":"0x04a093c37ab61065d00155
// {"new_balance":50000000000000000000,"tx_hash":null,"unit":"wei"}
```

### deployment of the new account
### Deployment of the new account

If you have sent enough funds to this new address, you can go forward to the final step:

Expand All @@ -91,7 +91,7 @@ Here, we will create a wallet with the Argent smart contract v0.3.0. The contrac
import { Account, ec, json, stark, RpcProvider, hash, CallData } from 'starknet';
```

### compute address
### Compute address

```typescript
// connect provider
Expand Down Expand Up @@ -124,7 +124,7 @@ If you want a specific private key, replace `stark.randomAddress`()` with your c

Then you have to fund this address.

### deployment of the new account
### Deployment of the new account

If you have sent enough funds to this new address, you can go forward to the final step:

Expand Down Expand Up @@ -223,8 +223,10 @@ The computed address has been funded automatically by minting a new dummy ETH in

## Create an Ethereum account

Thanks to account abstraction, you can create in Starknet an account that old the cryptographic logic of an Ethereum account. By this way, you can use Ethereum private and public keys.
OpenZeppelin has released an account contract for a such Ethereum account. Here an example of account creation in Sepolia Testnet.
Thanks to account abstraction, you can create an account in Starknet that holds the cryptographic logic of an Ethereum account. This way, you can use Ethereum private and public keys!
OpenZeppelin has released an account contract for such an Ethereum account.

Below is an example of account creation in Sepolia Testnet.

### Compute address

Expand All @@ -249,7 +251,7 @@ console.log('Pre-calculated ETH account address =', contractETHaddress);

Then you have to fund this address.

### deployment of the new account
### Deployment of the new account

If you have sent enough funds to this new address, you can go forward to the final step:

Expand All @@ -274,7 +276,7 @@ console.log('✅ New Ethereum account final address =', contract_address);

You are not limited to these 3 contracts. You can create your own contract for the wallet. It's the concept of Account Abstraction.

You can customize entirely the wallet - for example:
You can entirely customize the wallet - for example:

- use a different concept of keys.

Expand Down
28 changes: 12 additions & 16 deletions www/docs/guides/define_call_message.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ To construct your tuple:
const myTpl = { '0': '0x0a', '1': 200 };
```

### named tuple
### Named tuple

> [!IMPORTANT] Only for Cairo 0.
Expand Down Expand Up @@ -242,28 +242,24 @@ If your abi is requesting this type : `core::starknet::secp256k1::Secp256k1Point
- If you are using a calldata construction method using the Abi, you have just to use a 512 bits number (so, without parity) :

```typescript
const privateKeyETH = "0x45397ee6ca34cb49060f1c303c6cb7ee2d6123e617601ef3e31ccf7bf5bef1f9";
const privateKeyETH = '0x45397ee6ca34cb49060f1c303c6cb7ee2d6123e617601ef3e31ccf7bf5bef1f9';
const ethSigner = new EthSigner(privateKeyETH);
const ethFullPublicKey = await ethSigner.getPubKey(); // 512 bits number
const myCallData = new CallData(ethAccountAbi);
const accountETHconstructorCalldata = myCallData.compile(
"constructor",
{
public_key: ethFullPublicKey
}
);
const accountETHconstructorCalldata = myCallData.compile('constructor', {
public_key: ethFullPublicKey,
});
```

- If you are using a calldata construction method without the Abi, you have to send a tuple of 2 u256 :

```typescript
const ethFullPublicKey = "0x0178bb97615b49070eefad71cb2f159392274404e41db748d9397147cb25cf597ebfcf2f399e635b72b99b8f76e9080763c65a42c842869815039d912150ddfe"; // 512 bits number
const pubKeyETH = encode.addHexPrefix(encode.removeHexPrefix(ethFullPublicKey).padStart(128, "0"));
const ethFullPublicKey =
'0x0178bb97615b49070eefad71cb2f159392274404e41db748d9397147cb25cf597ebfcf2f399e635b72b99b8f76e9080763c65a42c842869815039d912150ddfe'; // 512 bits number
const pubKeyETH = encode.addHexPrefix(encode.removeHexPrefix(ethFullPublicKey).padStart(128, '0'));
const pubKeyETHx = cairo.uint256(addAddressPadding(encode.addHexPrefix(pubKeyETH.slice(2, -64))));
const pubKeyETHy = cairo.uint256(addAddressPadding(encode.addHexPrefix(pubKeyETH.slice(-64))));
const accountETHconstructorCalldata = CallData.compile([
cairo.tuple(pubKeyETHx, pubKeyETHy)
]);
const accountETHconstructorCalldata = CallData.compile([cairo.tuple(pubKeyETHx, pubKeyETHy)]);
```

### struct
Expand All @@ -290,7 +286,7 @@ await myContract.my_function(myArray);
> It's also applicable for Cairo `Span` type.
### complex types
### Complex types

You can mix and nest literals, arrays, structs, and tuples.

Expand Down Expand Up @@ -321,7 +317,7 @@ await myContract.my_function(param1, param2, param3, param4);

There are 12 methods using contract parameters. Some types are authorized for each method:

### list of parameters
### List of parameters

Only meta-class methods are using a list of parameters (as illustrated in the previous chapter).
A Meta-Class is a Class that has any of its properties determined at run-time. The Contract object uses a Contract's ABI to determine what methods are available.
Expand Down Expand Up @@ -494,7 +490,7 @@ const getResponse = await myAccount.get_bal(specialParameters, { parseRequest: f

To use with `parseRequest: false` (see hereunder).

### summary table for arguments
### Summary table for arguments

These types of arguments can't be used at your convenience everywhere. Here is a table showing which types can be used in which function:

Expand Down
9 changes: 5 additions & 4 deletions www/docs/guides/signature.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,11 @@ try {
All the previous examples are using the standard Starknet signature process, but you can also use the Ethereum one.

```typescript
const myEthPrivateKey = "0x525bc68475c0955fae83869beec0996114d4bb27b28b781ed2a20ef23121b8de";
const myEthAccountAddressInStarknet = "0x65a822fbee1ae79e898688b5a4282dc79e0042cbed12f6169937fddb4c26641";
const myEthPrivateKey = '0x525bc68475c0955fae83869beec0996114d4bb27b28b781ed2a20ef23121b8de';
const myEthAccountAddressInStarknet =
'0x65a822fbee1ae79e898688b5a4282dc79e0042cbed12f6169937fddb4c26641';
const myEthSigner = new EthSigner(myEthPrivateKey);
console.log("Complete public key =", await myEthSigner.getPubKey());
console.log('Complete public key =', await myEthSigner.getPubKey());
const sig0 = await myEthSigner.signMessage(message, myEthAccountAddressInStarknet);
console.log("signature message =", sig0);
console.log('signature message =', sig0);
```
2 changes: 1 addition & 1 deletion www/versioned_docs/version-5.24.3/guides/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ In this example, if you want to read the events recorded in the last 10 blocks,
```typescript
import { RpcProvider } from 'starknet';
const providerRPC = new RpcProvider({
nodeUrl: "{ nodeUrl: 'https://starknet-goerli.infura.io/v3/' + infuraKey }",
nodeUrl: 'https://starknet-goerli.infura.io/v3/' + infuraKey,
}); // for an Infura node on Testnet
const lastBlock = await providerRPC.getBlock('latest');
const keyFilter = [num.toHex(hash.starknetKeccak('EventPanic')), '0x8'];
Expand Down

0 comments on commit f121a75

Please sign in to comment.