-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add kakarot v1 docs (very light) (#532)
- adding a short explanation and a code snippet to get things started next steps: - flow diagram?
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Overview | ||
|
||
Kakarot is a provable EVM built on the Cairo ZK-VM, Starkware's turing complete and efficient ZK-VM. For more information, visit Kakarot's [documentation](https://docs.kakarot.org/starknet/architecture/understanding-kakarot). | ||
|
||
Kakarot on Starknet allows for EVM applications to interact with Starknet as well as interoperability between EVM tools and Cairo dApps. | ||
|
||
import { Callout } from "vocs/components"; | ||
|
||
<Callout type="warning"> | ||
starknet-react/kakarot is currently in preview. If you experience any issue, | ||
feel free to open an issue on | ||
[GitHub](https://github.com/apibara/starknet-react/tree/main/packages/kakarot). | ||
</Callout> | ||
|
||
Kakarot connectors allows EVM wallet users (non-Snaps Metamask, Rabby, Subwallet EVM, Phantom EVM) to connect to Starknet dApps (i.e. developped in Cairo) with an EVM wallet. | ||
It is a set of connectors based on [wagmi](https://wagmi.sh/) EVM connectors. | ||
|
||
The library is able to detect EVM connectors that the user has installed on their browser based on [EIP-6963](https://eips.ethereum.org/EIPS/eip-6963). | ||
|
||
## Getting Started | ||
|
||
:::code-group | ||
|
||
```bash [npm] | ||
npm add @starknet-react/kakarot | ||
``` | ||
|
||
```bash [pnpm] | ||
pnpm add @starknet-react/kakarot | ||
``` | ||
|
||
::: | ||
|
||
Here is an example code snippet to add Kakarot connectors in a dApp. | ||
|
||
```tsx twoslash | ||
import React from "react"; | ||
import { | ||
StarknetConfig, | ||
useInjectedConnectors, | ||
argent, | ||
braavos, | ||
publicProvider, | ||
voyager, | ||
} from "@starknet-react/core"; | ||
import { sepolia, mainnet } from "@starknet-react/chains"; | ||
import { Chain } from "@starknet-react/chains"; | ||
import { kakarotConnectors } from "@starknet-react/kakarot"; | ||
|
||
export function StarknetProvider({ | ||
children, | ||
defaultChain, | ||
}: { | ||
children: React.ReactNode; | ||
defaultChain: Chain; | ||
}) { | ||
const chains = [sepolia, mainnet]; | ||
const provider = publicProvider(); | ||
console.log("provider", provider); | ||
const { connectors } = useInjectedConnectors({ | ||
// Show these connectors if the user has no connector installed. | ||
recommended: [argent(), braavos(), ...kakarotConnectors(provider)], | ||
// Hide recommended connectors if the user has any connector installed. | ||
includeRecommended: "always", | ||
// Randomize the order of the connectors. | ||
order: "alphabetical", | ||
}); | ||
|
||
return ( | ||
<StarknetConfig | ||
chains={chains} | ||
connectors={connectors} | ||
provider={publicProvider()} | ||
explorer={voyager} | ||
defaultChainId={defaultChain.id} | ||
> | ||
{children} | ||
</StarknetConfig> | ||
); | ||
} | ||
``` | ||
|
||
## How It Works | ||
|
||
When using Kakarot on Starknet, users manipulate two addresses: | ||
|
||
- their EVM address (associated with their EOA's signing key or their ERC-4337 account); | ||
- an underlying Starknet account which address is derived from the user's EVM address. It can be queried using kakarot core smart contract's method `get_starknet_address(felt evm_address)` | ||
|
||
Wallet interaction: | ||
|
||
1. User connects their EVM wallet, the Kakarot Core smart contract deployed on Starknet resolves the Starknet address associated to the user's EVM account. | ||
1. Upon performing an action on a Starknet dApp with the Kakarot connector, a transaction targeting the [Kakarot Multicall Cairo Precompile](https://github.com/kkrt-labs/kakarot/blob/main/cairo_zero/kakarot/precompiles/kakarot_precompiles.cairo#L85) that will perform the expected call is generated. | ||
1. User is able to see their underlying Starknet address with the Kakarot connector, as well as access their transaction status and data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters