本篇文章給大家分享的是有關scatter配合硬件錢包怎樣實現EOS離線簽名,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
成都創新互聯公司是一家專業提供賓陽企業網站建設,專注與成都做網站、成都網站建設、成都外貿網站建設、H5頁面制作、小程序制作等業務。10年已為賓陽眾多企業、政府機構等服務。創新互聯專業網站設計公司優惠進行中。
自己寫個scatter調用,配合cleos可以實現任意命令調用。
1、scatter導入硬件錢包賬號
2、新建index.html,完整源碼如下
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <title>scatter離線簽名</title> <script src="https://cdn.scattercdn.com/file/scatter-cdn/js/latest/scatterjs-core.min.js"></script> <script src="https://cdn.scattercdn.com/file/scatter-cdn/js/latest/scatterjs-plugin-eosjs.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/eosjs@16.0.9/lib/eos.min.js"></script> </head> <body> 正在調用scatter.. <script> // Don't forget to tell ScatterJS which plugins you are using. ScatterJS.plugins( new ScatterEOS() ); // Networks are used to reference certain blockchains. // They let you get accounts and help you build signature providers. const network = { blockchain:'eos', protocol:'https', host:'nodes.get-scatter.com', port:443, chainId:'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906' } // First we need to connect to the user's Scatter. ScatterJS.scatter.connect('My-App').then(connected => { // If the user does not have Scatter or it is Locked or Closed this will return false; if(!connected) return false; const scatter = ScatterJS.scatter; // Now we need to get an identity from the user. // We're also going to require an account that is connected to the network we're using. const requiredFields = { accounts:[network] }; scatter.getIdentity(requiredFields).then(() => { // Always use the accounts you got back from Scatter. Never hardcode them even if you are prompting // the user for their account name beforehand. They could still give you a different account. const account = scatter.identity.accounts.find(x => x.blockchain === 'eos'); // You can pass in any additional options you want into the eosjs reference. const eosOptions = { expireInSeconds:60 }; // Get a proxy reference to eosjs which you can use to sign transactions with a user's Scatter. const eos = scatter.eos(network, Eos, eosOptions); // ---------------------------- // Now that we have an identity, // an EOSIO account, and a reference // to an eosjs object we can send a transaction. // ---------------------------- // Never assume the account's permission/authority. Always take it from the returned account. const transactionOptions = { authorization:[`${account.name}@${account.authority}`] }; const result = eos.transaction({ actions: [{ "account": "eosio", "name": "linkauth", "authorization": [{ "actor": "aaaaaaaaaaa", "permission": "active" } ], "data": "500f75193bc969c40000000000ea305580d3355c5de94c44000000e02ae94c44" } ] }).catch(error => { console.error(error); }); console.log('Success =>', JSON.stringify(result)); }).catch(error => { // The user rejected this request, or doesn't have the appropriate requirements. console.error(error); }); }); </script> </body> </html>
3、使用cleos命令配合參數-d -s生成未簽名交易,拷貝交易里的actions替換掉代碼里的actions
4、用瀏覽器打開index.html,這時候就會喚出scatter登錄,然后授權,最后在硬件錢包點確認
以上就是scatter配合硬件錢包怎樣實現EOS離線簽名,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注創新互聯行業資訊頻道。
網站題目:scatter配合硬件錢包怎樣實現EOS離線簽名
瀏覽路徑:http://m.newbst.com/article46/pjcshg.html
成都網站建設公司_創新互聯,為您提供電子商務、全網營銷推廣、網站維護、商城網站、手機網站建設、網站排名
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯