-
Notifications
You must be signed in to change notification settings - Fork 3
How to sign Ethereum transaction via KeyChain
Here you can find an instruction on how to sign an Ethereum transaction with KeyChain
-
Download and install KeyChain for MacOs
-
Generate the key
Start with the command wscat -c ws://localhost:16384/
and send the create command to generate the key
{
"command": "create",
"params":
{
"keyname": "my_key",
"encrypted": true,
"curve": "secp256k1",
"cipher": "aes256"
}
}You will get an extended name of the key which consists of the name you have given it as a prefix and the first 8 bytes of the hash. Note that from now on you should insert the extended key!
Insert your own extended name of the key! Do not copy the following code together with the key name that we use because it is specified here only as an example of how your key name might look like. Use your own key name!
Then request a public key via
{
"command": "public_key",
"params":
{
"keyname": "my_key@f9a1554e3f5e30c8"
}
}- Calculate the address from the publicKey
const ethUtil = require('ethereumjs-util');
const publicKey = 'YOUR_PUBLIC_KEY';
const fromAdd = ethUtil.publicToAddress(publicKey).toString('hex');- Transfer money to the address corresponding to the public key
In case you work with ropsten - https://faucet.ropsten.be/
- Check the balance on the address - it should have enough ether for a successful transfer.
web3.eth.getBalance(fromAdd)
.then(console.log);- Sign transaction with the key that you have generated
You can find an example of the code here
