buzzup-docs/wallet/personal_sign.mdx
2024-10-18 12:24:14 +08:00

29 lines
786 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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