BTC
ETH
HTX
SOL
BNB
查看行情
简中
繁中
English
日本語
한국어
ภาษาไทย
Tiếng Việt

Web3應用程序商店協議:為Web3應用程序的註冊和分發提供標準

W3.Hitchhiker
特邀专栏作者
2022-01-03 11:43
本文約6167字,閱讀全文需要約9分鐘
為用戶解決了資產安全、雲端儲存訪問權限等問題,一個無信任、安全和易於使用的應用層,一套智能合約向用戶提供了無信任協議層服務。
AI總結
展開
為用戶解決了資產安全、雲端儲存訪問權限等問題,一個無信任、安全和易於使用的應用層,一套智能合約向用戶提供了無信任協議層服務。

一級標題

Background(背景)

一級標題

一級標題

Background(背景)"Web3 App"目前,開發者可以通過區塊鏈上的一套智能合約向用戶提供無信任協議層服務。但是,典型的日常用戶不會有可以直接理解和使用這些智能合約的能力——因此,他們需要一個無信任、安全和易於使用的應用層。https://app.uniswap.org應用層開發人員部署了易於使用的用戶界面,以幫助用戶與協議和代幣直接互動。這些應用程序大多會嘗試連接到用戶的Web3錢包,並直接請求籤名。

我們將這些應用程序稱為

。例如,Uniswap的官方網絡應用,託管在

,是一個典型的Web3應用,它將幫助用戶在區塊鏈上與自己的協議進行互動。以下是Uniswap的應用程序和協議的技術結構:

隨著協議層上的智能合約與相應的Web3應用程序一起激增,但我們仍然能看到目前行業實踐中有兩個關鍵的問題,即圍繞可訪問性和安全性。

Security(安全性)

Security(安全性)

一級標題

其次,目前大多數用戶通過Web瀏覽器和Web3插件的組合來訪問Web3應用程序,這個過程充滿了安全問題。這就使項目組和黑客都有機會在Web3應用程序中嵌入新的惡意代碼,從而竊取用戶的資產。

一級標題

一級標題Specification(規格)Web3應用程序商店協議我們提出了一個Web3應用商店協議來解決上述的可訪問性和安全性問題。這些應用商店應該包含一個基於智能合約的Web3應用註冊中心(Web3 App Registry)

,一個基於圍繞權限、版本描述、規格等存儲在鏈外的元數據的Web3應用程序包,以及一個安裝在用戶本地設備上的Web3應用商店客戶端。之後,我們還需要Web3審核員(auditors)來幫助用戶審核Web3應用程序的源代碼。這些組件之間的關係如下所示。Web3應用註冊中心(Web3 App Registry)

是一套基於Web3 App註冊標準(Web3 App Registration Standard)的智能合約。團體(Orgs)和個人可以無權限地建立他們自己的Web3應用程序註冊中心。 Web3開發者可以使用他們的鏈上賬戶在該註冊中心中註冊他們的Web3應用程序,並對安裝包的發行版和校驗和(checksum)進行版本管理。審核員可以無權限地使用他們的鏈上賬戶來審核所有這些應用程序,並在註冊表中公佈結果。Web3應用程序包(Web3 App Packages)

是指由開發商發布的軟件,供用戶在其本地設備上安裝Web3應用程序。這些軟件包可以存儲在任何中心化或去中心化的存儲服務中,軟件包的網址和校驗和應記錄在註冊表上。同時,在基於Web3應用配置標準(Web3 Application Configuration Standard)上,在軟件包的根部應該有一個包含Web3應用的權限聲明和版本描述的配置文件。源代碼的存儲路徑應被指定在配置文件中,以便審計人員能夠輕鬆獲取源代碼進行審計。Web3應用商店客戶端(Web3 App Store Client)

是安裝在用戶本地設備上的軟件。團體和個人可以在

Web3應用商店客戶端標準(**App Store Client Standard)

的基礎上自由地建立自己的應用商店客戶端。客戶端可以同時連接到一個或多個註冊中心。它需要從註冊表中獲取Web3應用程序列表、版本信息和審計信息。當用戶安裝或更新一個Web3應用程序時,需要自動獲取安裝包。然後驗證軟件包的校驗和(checksum)是否與註冊中心中的校驗和(checksum)相等。最後,它應該告訴用戶這個Web3應用需要多少權限。而在用戶確認權限後,Web3 App將被安裝在本地設備上。

這種設計框架確保了Web3應用程序的可訪問性,是因為用戶可以繼續使用舊的本地版本——並有權根據新的註冊中心和新的應用程序包進行升級。

pragma solidity ^0.8.0;
/**
* @title AppRegistration interface
*/
interface IAppRegistration {
   struct auditorVote {
       address auditor;
       uint8 level;
   }
   function createApp() external returns (uint256);
   function addVersion(uint256 appId, string memory versionId, string memory fileUrl) external;
   function getAppIds() external returns (uint256[] memory);
   function getVersions(uint256 appId) external returns (string[] memory);
   function getVersionFileUrl(uint256 appId, string memory versionId) external view returns (string memory);
   function voteApp(uint256 appId, uint8 level) external;
   function voteAppVersion(uint256 appId, string memory versionId, uint8 level) external;
   function getVotes(uint256 appId, string memory versionId) external returns (auditorVote[] memory);
}

同時,客戶端會將本地軟件包的校驗和與註冊中心中的校驗和(checksum)進行驗證,從而避免了黑客或項目組的更改機會,並確保用戶使用的應用程序與鏈上註冊中心中公佈的應用程序一致。而軟件包中的配置文件也指向了當前版本的源代碼,審核員就可以通過校驗和(checksum)來驗證該軟件包是由這些源代碼打包而成的。它將確保源代碼和安裝包之間的一致性,然後確保用戶使用的是經審計師審計過的安全包。

{
 "properties": {
   "name": {
     "title": "Name of the App",
     "type": "string"
   },
   "logoUrl": {
     "title": "Logo of the App",
     "type": "string"
   },
   "description": {
     "title": "Description of the App",
     "type": "string"
   },
   "origin": {
     "title": "Online dapp origin",
     "type": "string",
     "pattern": "^((https|http)?:\\/\\/)[^\\\\s]+"
   },
   "permissions": {
     "properties": {
       "web3Provider": {
         "requestAccount": {
           "title": "If App need permission to connect with wallet",
           "type": "boolean"
         },
         "personalSign": {
           "properties": {
             "request": {
               "type": "boolean",
               "title": "If App need permission to request sign text message"
             },
             "patterns": {
               "type": "array",
               "title": "Patterns of text message"
             }
           },
           "title": "Declaration for sign text message",
           "type": "object"
         },
         "transaction": {
           "properties": {
             "request": {
               "type": "boolean",
               "title": "If App need permission to request transaction"
             },
             "contractCalls": {
               "type": "array",
               "title": "Declaration for contrat transaction"
             },
             "tokenApproves": {
               "type": "array",
               "title": "Declaration for token approval"
             },
             "ERC20TokenTransfer": {
               "type": "array",
               "title": "Declaration for ERC20 token transfer transaction"
             }
           },
           "type": "object",
           "title": "Declaration for transaction"
         },
         "network": {
           "urlPatterns": {
             "type": "array",
             "title": "Patterns of whitelist network request URL"
           },
           "title": "Declaration for APP network request",
           "type": "object"
         },
         "title": "Declaration for Web3Provider permissions",
         "type": "object"
       }
     },
     "title": "Declaration for App permissions",
     "type": "object"
   },
   "app": {
     "properties": {
       "id": {
         "title": "AppId allocated by App Store",
         "type": "string"
       },
       "chainId": {
         "title": "The chainId which App Store deployed",
         "type": "string"
       },
       "contract": {
         "title": "The contract address of App Store",
         "type": "string"
       }
     },
     "type": "object",
     "title": "App information on App Store"
   },
   "source": {
     "properties": {
       "repository": {
         "type": "string",
         "title": "The URL that can access App source code",
         "pattern": "^(https:\\/\\/|git@)[^\\\\s]+"
       },
       "buildScript": {
         "type": "string",
         "title": "The script that can complie source code to bundles"
       },
       "systemEnvironment": {
         "type": "string",
         "title": "The system environment that can make sure auditor can build bundle which has the same SHA256"
       }
     },
     "type": "object",
     "title": "Information of source code for auditor use"
   }
 },
 "title": "Web3 App json config file",
 "type": "object"
}

當用戶使用Web3應用程序時,客戶端也會根據用戶之前確認的應用程序的權限聲明來限制這些應用程序的權限。然後完全保證用戶在訪問本地Web3服務時的安全。

interface App {
 app: {
   id: string
   chainId: string
   contract: string
 }
 permissions: {
   network: {
     urlPatterns: string[]
   },
   web3Provider: {
     requestAccount: boolean
     personalSign: {
       request: boolean
       patterns: string[]
     },
     transaction: {
       request: boolean
       contractCalls: ContractCallItem[]
       tokenApproves: TokenApproveItem[]
       ERC20TokenTransfer: ERC20TokenTransferItem[]
     }
   }
 }
 source: {
   repository: string
   buildScript: string
   systemEnvironment: string
 }
 appId: number
 domain: string
 versionId: string
 files: string[]
 name: string
 description?: string
 logoUrl: string
}
enum VoteLevel {
 DANGER = -1
 UNKNOW = 0
 SAFE = 1
}
class Web3AppStore {
 chainId: string; // The chainId which App Store deployed
 
 contract: string; // The contract address of App Store
 
 getApps(): Promise
 
 getApp(appId: number, version?: string): Promise
 
 getAppVersions(appId: number): Promise

 createApp(): Promise
 
 addVersion(appId: number, fileUrls: string[]): Promise
 
 voteApp(appId: number, level: VoteLevel): Promise
 
 voteAppVersion(appId: number, versionId: string, level: VoteLevel): Promise
 
 // Validate the SHA256 of App file is same as versionId of not
 validateAppVersion(app: App): Promise
 
 // Validate if the domain which declared in domain property has the same web3.json file of current App
 validateAppDomain(app: App): Promise
}

Releases

No releases published

Packages

No packages published

Web3.0
歡迎加入Odaily官方社群