You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
786 B

1 month ago
  1. ---
  2. title: personal_sign
  3. description: 连接钱包并且签名,personal_sign- 使用此方法可以最轻松地请求不需要在链上有效处理的人性化签名。此方法要求用户首先授予与其帐户交互的权限,因此请确保先调用eth_requestAccounts
  4. ---
  5. ---
  6. ### 参数
  7. - message: (必填) 签名数据
  8. - address: (必填) 地址
  9. ---
  10. ### 返回值
  11. - <div>Signature<span style={{marginLeft:10,color:'#707070'}}>hex encoded bytes</span></div>
  12. ---
  13. ```js
  14. async function personal_sign() {
  15. try {
  16. const signature = await window.ethereum.request({
  17. method: 'personal_sign',
  18. params: [message, address],
  19. });
  20. console.log('签名结果:', signature);
  21. } catch (error) {
  22. console.log('签名失败:', signature);
  23. }
  24. }
  25. ```