Skip to content

feat: accounts sdk v1 #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: sdk-v1-new
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions docs/sdk/03_accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,87 @@
id: accounts
title: Accounts
---

import TsJsBlock from '@site/src/components/TsJsBlock';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## Create

## Update

## Delete

## Query

Sometimes there is the need to link a DID to an account publicly.
The link makes it possible to lookup a DID for an account.
The other directions is also possible.
With a DID you can lookup a list of linked account.

Linking accounts can be useful when your account should have an identity.
E.g. as a collator, you might want to provide some public information so that delegator can better decide who earned their stake.

An account can be linked to a DID in one of two ways.
Either the account that sends the transaction links itself to the DID, or the sender is unrelated to the DID and a third account is linked.
In the latter case, a challenge needs to be signed using the third account, to prove ownership.

The second option is useful in cases where the account that should be linked doesn't own KILT tokens and the transaction is paid for by a third party.
This option also allows to link account schemes that are not native to the Spiritnet Blockchain.
Right now the only other address scheme supported are ethereum accounts.

:::warning Don't use linked accounts for asset transfers

Don't use these linked accounts for asset transfers.
Since these accounts are not limited to KILT accounts, but can be used on any chain, the recipient might not be able to access the transferred asset on other chains.
When a link to an account on a different Polkadot chain is created, this account might only be usable on this specific chain.

If you want transfer assets to a DID have a look at [the asset transfer service](https://github.com/KILTprotocol/spec-KiltTransferAssetRecipientV1).

:::

## Linking the sender to a DID

Link the sender of the transaction to the DID.
The sender will provide the deposit and pay the fees.
They will also be linked to the DID.

## Linking an account to a DID

Link another account to the DID.
The sender will provide the deposit and pay the fees, but will not be linked to the DID in any way.
The account that should be linked must sign a challenge to prove that the account agrees to be linked.

The proof contains the DID that the account will be linked to and an expiration date (in terms of blocks), to prevent replay attacks.
The proof will only be valid up until the blocknumber is reached.

With this option you can link addresses that are supported by the Spiritnet blockchain (Sr25519, Ed25519, Ecdsa), but also ethereum addresses.

<Tabs
defaultValue="substrate-link"

>

</Tabs>

## Query the web3name of an Account

For accounts that have been linked to DIDs that have claimed a web3name, the linking feature opens the way to a host of possibilities, e.g., showing the web3name of a collator's account on the [KILT Stakeboard][kilt-stakeboard].

This section shows how to perform the `account -> web3name` querying both with and without the support of the KILT SDK.

## Query an Account's web3name with the KILT SDK

## Query an Account's web3name without the KILT SDK

[kilt-stakeboard]: https://stakeboard.kilt.io/

## Unlink an Account From a KILT DID

Similar to the way a new account to DID link is created, removing a link can happen in one of three ways:

1. The DID owner submits a transaction indicating which account to unlink:

2. The linked account submits a transaction indicating that the link with the DID should be removed:

3. The deposit payer submits a transaction indicating that they want to reclaim their deposit, which in turn removes the existing link between the specified account and DID:
Loading