diff --git a/README.md b/README.md index 2d967620..f3f43bb1 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,9 @@ help developers to participate with Hackathons. The project includes: - `starkpiller` is a demo application that uses the `burner` to mint and burn Stark pills. +To use the burner wallet, check the +[Getting Started](./docs/getting-started.md) guide. + ## Special thanks to - [Austin Griffith](https://twitter.com/austingriffith) for the original @@ -46,4 +49,3 @@ help developers to participate with Hackathons. The project includes: - [0xs34n](https://twitter.com/0xs34n) from [aspect.co](https://twitter.com/aspectdotco) for building and maintaining [starknet-js](https://github.com/0xs34n/starknet.js). - diff --git a/burner/src/lib/Burner.svelte b/burner/src/lib/Burner.svelte index 2d5a46cf..269be50f 100644 --- a/burner/src/lib/Burner.svelte +++ b/burner/src/lib/Burner.svelte @@ -26,7 +26,7 @@
{#if !$wallet.isLoggedIn} - + loading... {:else if $burner.state == 'renewkey'} {:else if $burner.state == 'keys' || !$wallet.token?.account} diff --git a/burner/src/lib/ts/keys.ts b/burner/src/lib/ts/keys.ts index 1c819097..702f2516 100644 --- a/burner/src/lib/ts/keys.ts +++ b/burner/src/lib/ts/keys.ts @@ -18,6 +18,19 @@ export const loadKeys = () => { let sessPublicKey = ec.getStarkKey(keypair); let bwtk = localStorage.getItem('bwtk'); if (!bwtk || bwtk === '') { + wallet.update((data) => { + let token = { + sessionkey: sessPublicKey as string, + expires: 0, + token: ['', ''], + account: '' + }; + return { + ...data, + token, + isLoggedIn: true + }; + }); return; } let tokenData = JSON.parse(bwtk); diff --git a/docs/getting-started.md b/docs/getting-started.md new file mode 100644 index 00000000..88ec4919 --- /dev/null +++ b/docs/getting-started.md @@ -0,0 +1,152 @@ +## Getting started + +The burner wallet is a Javascript Wallet that works on a browser, including on +your mobile phone. It relies on an upgraded argent-x account that supports +plugins. To use it, you should: + +1. make sure your account is changed with ETH and Starkpill tokens. +2. upgrade the argent-x account to an argent-x account that supports plugins +3. add the plugin that checks a specific signature to your account +4. connect to the burner wallet and generate a session key +5. send the session key to the drone application that will help you to sign + it and send a session token back to the application +6. register the session token with the burner wallet +7. play with the wallet + +> Before you start, the current plugin is not secure and granting access to +> the burner wallet will enable the user to use your account for any purpose. +> For now, it is only available on the testnet (goerli) and you should use it +> on a separate account. + +### Make sure your account is charged + +Before you proceed further, make sure your account is charged with ETH and +Stark Pills as it might be useful. + +### Upgrading your contract + +The upgraded contract is `contracts/ArgentAccount.cairo` available from the +[bugfix/session-key](https://github.com/gregoryguillou/argent-contracts-starknet/tree/bugfix/session-key) +branch of a fork of the argent-x contract. A compiled version of it is +available in the `plugin/contracts` folder as `argentaccount_plugin.json`. The +class hash of the contract is `0x443e7c09ffda6b7cf5fe88fb18eb0a78d285db8ef8277c3918326d476c73efa`. + +To upgrade your account, copy the account address from the argent-x extension, +navigate to [voyager](https://goerli.voyager.network) and check your contract. +Go to the `Write Contract` method and run the `upgrade` function with new +contract address like below: + +![Run Upgrade Account](./img/upgrade-account.png) + +To check the implementation has changed, you should wait for the contract to be upgraded +and check the contract in voyager. You should see in the `Write Contract` methods, there +is a `add_plugin` function. Another way is to open the Argent-x extension, you should +now see that the extension detects it is not its original contract and requests you to +upgrade it back (**do not** use the `Upgrade` function). + +![Run Upgrade Account](./img/upgrade-account.png) + +You might also use the `proxy_abi.json` file in `plugin/contracts` and check +the implementation has changed from the starknet CLI. + +```shell +export MYACCOUNT=0x... +starknet call \ + --address $MYACCOUNT \ + --function get_implementation \ + --abi proxy_abi.json +``` + +### Add the plugin that checks a specific signature + +Plugins are relying on a specific signature that depends from the website and +uses a specific scheme inpired from EIP-712 that `starknet.js` and `argent-x` +implement. As a result, the plugin embeds some properties that should help +people to check the website it is supposed to use. We have developed a plugin +that uses the `starknet.burner` domain. To check the code, see the +[`SessionKey.cairo`](../plugin/src/SessionKey.cairo) file in `plugin/src` +folder. We have deployed the plugin on the testnet (goerli) and the plugin +class hash is +`0x377e145923e881f59d62269a46057d8dac67e27d68a12679b198d4224a0966b`. + +To add the plugin to your account, copy the account address from the argent-x +extension, navigate to [voyager](https://goerli.voyager.network) and check your +contract. Go to the `Write Contract` method and run the `add_plugin` function +with the plugin hash like below: + +![Add plugin](./img/add_plugin-account.png) + +To check the implementation has changed, you should wait for the plugin to be added +and check the contract in voyager. You should see in the `Read Contract` methods, there +is a `is_plugin` function. You can use it with the Plugin Hash. + +You might also use the `argentaccount_plugin_abi.json` file in `plugin/contracts` and +check the implementation has changed from the starknet CLI. + +```shell +export MYACCOUNT=0x... +starknet call \ + --address $MYACCOUNT \ + --function is_plugin \ + --abi argentaccount_plugin_abi.json \ + --inputs 0x377e145923e881f59d62269a46057d8dac67e27d68a12679b198d4224a0966b +``` + +### First Burner Wallet connection + +To start the burner wallet, run: + +```shell +cd burner +npm install +npm run dev +``` + +When you connect to the burner wallet, for the first time, you get a string +asking for the account and session tokens like below: + +![firt burner connection](./img/burner-1stconnection.png) + +You can copy the session key; we will use it with the drone application to +grant access to the burner wallet. + +### Connect to the drone application + +To start drone, run: + +```shell +cd drone +npm install +npm run dev +``` + +When you connect to drone, it requests for a session key like below: + +![first drone connection](./img/drone-1stconnection.png) + +You can copy the session key and click on the sign button. It will connect to +your argent-x extension and request to sign the session key. Once you have +signed the session key, it will provide the session token to the burner wallet. + +![drone signature](./img/drone-signing.png) + +### Register the session token with the burner wallet + +You can copy the URL from drone, and use it from your browser and it should +reload the burner wallet this time with the session token and the associated +account. Check it is correctly loaded by clicking on the `Keys...` button, the +keys screen should look like below: + +![second burner connection](./img/burner-2ndconnection.png) + +### You are ready to use the burner wallet + +You can click on the `Send...` button and send Starkpill tokens to whoever you +want from the burner wallet... + +### To continue... + +If you like it, add a star to the project on +[GitHub](https://github.com/dontpanicdao/starknet-burner). If you need more +features or have questions, open an issue or contact us on the Starknet +Discord. diff --git a/docs/img/add_plugin-account.png b/docs/img/add_plugin-account.png new file mode 100644 index 00000000..4efd412f Binary files /dev/null and b/docs/img/add_plugin-account.png differ diff --git a/docs/img/burner-1stconnection.png b/docs/img/burner-1stconnection.png new file mode 100644 index 00000000..7deeaf0f Binary files /dev/null and b/docs/img/burner-1stconnection.png differ diff --git a/docs/img/drone-1stconnection.png b/docs/img/drone-1stconnection.png new file mode 100644 index 00000000..4a6770fa Binary files /dev/null and b/docs/img/drone-1stconnection.png differ diff --git a/docs/img/drone-signing.png b/docs/img/drone-signing.png new file mode 100644 index 00000000..157e7738 Binary files /dev/null and b/docs/img/drone-signing.png differ diff --git a/docs/img/upgrade-account.png b/docs/img/upgrade-account.png new file mode 100644 index 00000000..94834122 Binary files /dev/null and b/docs/img/upgrade-account.png differ