Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement EOS offline signature with scatter and hardware wallet

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how scatter works with hardware wallet to achieve EOS offline signature. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.

Write a scatter call by yourself, and you can call any command with cleos.

1. Scatter imports the hardware wallet account.

2. Create a new index.html. The complete source code is as follows

Scatter offline signature is calling scatter..// 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);})

3. Use the cleos command with the parameter-d-s to generate an unsigned transaction, and copy the actions in the transaction to replace the actions in the code.

4. Open index.html with a browser, and then call scatter login, then authorize it, and finally confirm it at the hardware wallet point.

This is how scatter cooperates with hardware wallet to achieve EOS offline signature. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report