Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する

Get the endpoint of DID Space when you first log in to the application.

JianChao
2024-04-15 11:24
· edited

Overview#

When you want your application to store each user's data in their own DID Space, you can require users to bind their DID Space during their first login through certain settings, authorizing your application to access the user's own DID Space.

Prerequisite#

Operation process#

Requesting users to present DID Space NFT.#

When the user first logs into your application, they must present their own DID Space NFT.

image.png

After successfully presenting the DID Space, users can click on Profile, then click on the Settings icon in the top right corner, and switch to the Storage tab to see the just connected DID Space.

image.png

image.png

The application reads the user's DID Space endpoint.#

At this point, when the application is running, you can obtain the user's DID Space endpoint through the following code:

const AuthService = require('@blocklet/sdk/service/auth');

const authService = new AuthService();
const { user } = await authService.getUser(userDid);

console.log(user.didSpace.endpoint);
// 输出形如: https://space.team.arcblock.io/app/api/space/zNKhe8jwgNZX2z7ZUfwNddNECxSe3wyg7VtS/app/zNKfEK9actwBeLhfVvc9U1p1CqVWxtivVxo6/object/

After obtaining the DID Space endpoint, you will be able to read and write data on DID Space, refer to: https://www.arcblock.io/docs/did-spaces/zh/24293819-b746-4ae1-89be-07e9477b04f9


Sticker