Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use php to implement EOS offline signature transaction

Shulou Source: shulou.com Published: 2022-06-01 19:47:15 09月26日 Update

This article is about how to use php to implement EOS offline signature transactions. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Keosd, the wallet server of the EOS blockchain, provides a sign_transaction development interface that allows developers to sign transactions. But if we want to manage the key ourselves instead of handing it over to keosd, how can we implement the offline signature of the transaction in the PHP code?

The answer is to use EosTool, the PHP package for EOS application development. EosTool's LocalSigner class makes it easy to sign EOS transactions offline. For example, the following code uses a private key that it manages to sign a token transfer transaction:

Use EosTool\ Signer\ LocalSigner $tx = ['expiration'= >' 2018-12-04T17VIED 00V, 'ref_block_num' = > 2878,' ref_block_prefix' = > 29012031, 'max_net_usage_words' = > 0,' max_cpu_usage_ms' = > 0, 'delay_sec' = > 0,' context_free_actions' = > [], 'actions' = > [' account' = > 'eosio.token',' name' = > 'transfer'' 'authorization' = > [[' actor' = > 'eosio',' permission' = > 'active']],' data' = > '11223344556677889900112233456677.889900']],' transaction_extensions' = > [] $pubKeys = [...]; $chainId = '...'; $signer = new LocalSigner (['5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'] / * private keys*/); $signatures = $signer- > sign ($tx,$pubKeys,$chainId)

To instantiate LocalSigner, you need to pass in a set of private keys for signature, and then call its sign () method to pass in the transaction initiation account public key array and chunk chain ID. The returned result is the authoritative signature array of the transaction.

Thank you for reading! On "how to use php to achieve EOS offline signature transactions" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!

Tags: Trading development management code content blocks arrays more articles good practical public keys functions examples keys that is application development developers interfaces articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Linux vpn Apple OPPO Reno