Skip to content

Commit

Permalink
update the 📕 documentation with a getting-started.md (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoryguillou authored Jul 16, 2022
1 parent 7f523b4 commit 2d620d5
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).

2 changes: 1 addition & 1 deletion burner/src/lib/Burner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<div class="burner">
{#if !$wallet.isLoggedIn}
<button on:click={connect}>Log</button>
loading...
{:else if $burner.state == 'renewkey'}
<RenewKeys />
{:else if $burner.state == 'keys' || !$wallet.token?.account}
Expand Down
13 changes: 13 additions & 0 deletions burner/src/lib/ts/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
152 changes: 152 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -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.
Binary file added docs/img/add_plugin-account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/burner-1stconnection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/drone-1stconnection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/drone-signing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/upgrade-account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2d620d5

Please sign in to comment.