Anh Nguyen
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Gno Wallet Standard ## Summary The Wallet standard defines a universal API for wallet and application interactions. This doc introduces a wallet standard for the Gno ecosystem. ## Motivation Most web wallets today are browser extensions. They interact with dApps by injecting themselves into the global window object, expecting the dApp to detect them by reading this object. This approach has several issues: 1. DApps must know how to find these objects and often support only a limited number of wallets, which might not be relevant to users. 2. DApps need to continuously scan the window object to detect wallets injected before and after loading, leading to constant background processes. 3. This detection method can cause race conditions if a dApp loads before a wallet, potentially missing new wallets. This proposal suggests adopting a generalized event-based communication model between wallets and dApps in Gno to address all these issues. ## Rationale This [chain agnostic solution](https://github.com/wallet-standard/wallet-standard) has been introduced as a generalized standard for wallets and dapps communication and has already been implemented on [Solana](https://github.com/wallet-standard/wallet-standard) and [Sui](https://docs.sui.io/standards/wallet-standard), and the [Ethereum](https://eips.ethereum.org/EIPS/eip-6963) community recently proposed a similar solution. ## Specification The Wallet Standard is a chain-agnostic set of interfaces and conventions designed to improve how applications interact with injected wallets. The Gno team will create a similar repository (https://github.com/aptos-labs/wallet-standard) to specify which APIs must or should be implemented for wallets. **Standard Features** `gno:connect` method to establish a connection between a dapp and a wallet. ```ts // `silent?: boolean` - gives ability to trigger connection without user prompt (for example, for auto-connect) // `networkInfo?: NetworkInfo` - defines the network that the dapp will use (shortcut for connect and change network) connect(silent?: boolean, networkInfo?: NetworkInfo): Promise<UserResponse<AccountInfo>>; ``` `gno:disconnect` method to disconnect a connection established between a dapp and a wallet ```ts disconnect(): Promise<void>; ``` `gno:getAccount` to get the current connected account in the wallet ```ts getAccount():Promise<UserResponse<AccountInfo>> ``` `gno:getNetwork` to get the current network in the wallet ```ts getNetwork(): Promise<UserResponse<NetworkInfo>>; ``` `gno:signTransaction` for the current connected account in the wallet to sign a transaction using the wallet. ```ts // `transaction: AnyRawTransaction` - a generated raw transaction created with Gno’ TS SDK signTransaction(transaction: AnyRawTransaction):AccountAuthenticator ``` `gno:signMessage` for the current connected account in the wallet to sign a message using the wallet. ```ts // `message: GnoSignMessageInput` - a message to sign signMessage(message: GnoSignMessageInput):Promise<UserResponse<GnoSignMessageOutput>>; ``` `gno:onAccountChange` event for the wallet to fire when an account has been changed in the wallet. ```ts // `newAccount: AccountInfo` - The new connected account onAccountChange(newAccount: AccountInfo): Promise<void> ``` `gno:onNetworkChange` event for the wallet to fire when the network has been changed in the wallet. ```ts // `newNetwork: NetworkInfo` - The new wallet current network onNetworkChange(newNetwork: NetworkInfo):Promise<void> ``` `gno:signAndSubmitTransaction*` method to sign and submit a transaction using the current connected account in the wallet. ```ts // `SignAndSubmitTransactionInput` - the transaction details in a JSON format signAndSubmitTransaction(SignAndSubmitTransactionInput): Promise<UserResponse<{string:hash}>>; ``` `gno:changeNetwork*` event for the dapp to send to the wallet to change the wallet’s current network ```ts // `network:NetworkInfo` - The network for the wallet to change to changeNetwork(network:NetworkInfo):Promise<UserResponse<{success: boolean,reason?: string}>> ``` **Types** > Note: `UserResponse` type is used for when a user rejects a rejectable request. For example, when user wants to connect but instead closes the window popup. ```ts export enum UserResponseStatus { APPROVED = 'Approved', REJECTED = 'Rejected' } export interface UserApproval<TResponseArgs> { status: UserResponseStatus.APPROVED args: TResponseArgs } export interface UserRejection { status: UserResponseStatus.REJECTED } export type UserResponse<TResponseArgs> = UserApproval<TResponseArgs> | UserRejection; export interface AccountInfo = { account: Account, ansName?: string } export interface NetworkInfo { name: Network chainId: number url?: string } export type GnoSignMessageInput = { TBD } export type GnoSignMessageOutput = { TBD } ``` **Errors** A wallet must throw a GnoWalletError. The standard requires to support `Unauthorized` and `InternalError` but a wallet can throw a custom `GnoWalletError` error Using the default message ```ts if (error) { throw new GnoWalletError(GnoWalletErrorCode.Unauthorized); } ``` Using a custom message ```ts if (error) { throw new GnoWalletError( GnoWalletErrorCode.Unauthorized, "My custom unauthorized message" ); } ``` Using a custom error ```ts if (error) { throw new GnoWalletError(-32000, "Invalid Input"); } ``` **Register and Get Wallet** After you have a compatible interface for your wallet, use the registerWallet function to register it. ```ts registerWallet(new YourWallet()); ``` To query the installed wallets in a user's browser, use the get function of getWallets. ```ts const availableWallets = getWallets().get(); ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully