Skip to content

How to sign Ethereum transaction via KeyChain

Avvrik edited this page Jan 11, 2019 · 43 revisions

Here you can find an instruction on how to sign an Ethereum transaction with KeyChain.

Demo page

Here you can try out signing Ethereum transactions with KeyChain.

1. Download and install KeyChain for macOS or Windows

2. 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"
  }
}

NB:

Insert your own key name! 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.

Then request a public key via

{ 
  "command": "public_key",
  "params": 
  {
    "keyname": "my key"
  }
}

3. Calculate the address from the publicKey

const ethUtil = require('ethereumjs-util');
const publicKey = 'YOUR_PUBLIC_KEY';
const fromAdd = ethUtil.publicToAddress(publicKey).toString('hex');

4. Transfer money to the address corresponding to the public key

In case you work with ropsten - https://faucet.ropsten.be/

5. Check the balance on the address - it should have enough ether for a successful transfer.

web3.eth.getBalance(fromAdd) 
.then(console.log);

6. Sign transaction with the key that you have generated

You can find an example of the code here

screen shot 2018-11-30 at 19 19 52