Skip to content

Commit 48ee4ac

Browse files
authored
Update README.md
1 parent c92ca9f commit 48ee4ac

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,26 @@ NB: If you launch KeyChain for the first time, you need to get a public key with
5555
1. Install `keychain.js` library from this [source](https://www.npmjs.com/package/keychain.js).
5656

5757
```
58-
npm i keychain.js
58+
npm install keychain.js
5959
```
6060

6161
2. Now use an overridden web3 function
6262

6363
```javascript
64-
const { Keychain, keychainWeb3 } = require('keychain.js');
64+
const { Keychain, KeychainWeb3 } = require('keychain.js');
6565
const Web3 = require('web3');
66-
const API_KEY = 'https://ropsten.infura.io/v3/YOUR_ID';
67-
const web3 = new Web3(new Web3.providers.HttpProvider(API_KEY));
66+
const API_URL = 'YOUR_API_URL'; // https://ropsten.infura.io/v3/046804e3dd3240b09834531326f310cf
67+
const web3 = new Web3(API_URL);
6868
const transactionParams = {
6969
to: '0xE8899BA12578d60e4D0683a596EDaCbC85eC18CC',
7070
value: 100,
7171
gas: 21000
7272
};
73-
// now we are using web3 with keychain
74-
web3.eth.accounts.signTransaction = keychainWeb3.signTransaction.bind(web3);
7573
const keychain = new Keychain();
74+
const keychainWeb3 = new KeychainWeb3(keychain, web3);
7675
keychain.selectKey()
77-
.then(publicKey => web3.eth.accounts.signTransaction(transactionParams, publicKey))
78-
.then(result => {
79-
console.log('result.rawTransaction:', result.rawTransaction);
80-
console.log('Send signed transaction with web3.eth.sendSignedTransaction(result.rawTransaction)')
81-
});
76+
.then(publicKey => keychainWeb3.signTransaction(transactionParams, publicKey))
77+
.then(result => web3.eth.sendSignedTransaction(result.rawTransaction));
8278
```
8379

8480
`signTransaction` with KeyChain in action

0 commit comments

Comments
 (0)