web3.js web3.eth.sign
web3.eth.sign(dataToSign, address [, callback])
特定のアカウントを使用して、データに署名をします。
アカウントはアンロックされている必要があります。
パラメータ
1. String
サインするデータ
2. String|Number
データをサインするアドレス
3. Function
オプショナル
コールバック
第一引数に error オブジェクト、第二引数に result オブジェクトが渡されます。
注意
戻り値
String を返す Promise
署名
サンプル
code:example.js
web3.eth.sign("Hello world", "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe")
.then(console.log);
"0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400"
// the below is the same
web3.eth.sign(web3.utils.utf8ToHex("Hello world"), "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe")
.then(console.log);
"0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400"
参考
関連