Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #452
- Loading branch information
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## `deriveKey` | ||
|
||
### Signature | ||
|
||
```solidity | ||
function deriveKey( | ||
string calldata mnemonic, | ||
uint32 index | ||
) external returns (uint256); | ||
``` | ||
|
||
```solidity | ||
function deriveKey( | ||
string calldata mnemonic, | ||
string calldata path, | ||
uint32 index | ||
) external returns (uint256); | ||
``` | ||
|
||
### Description | ||
|
||
Derive a private key from a given mnemonic or mnemonic file path. | ||
|
||
The first signature derives at the derivation path `m/44'/60'/0'/0/{index}`. | ||
The second signature allows you to specify the derivation path as the second parameter. | ||
|
||
### Examples | ||
|
||
Derive the private key from the test mnemonic at path `m/44'/60'/0'/0/0`: | ||
|
||
```solidity | ||
string memory mnemonic = "test test test test test test test test test test test junk"; | ||
uint256 privateKey = vm.deriveKey(mnemonic, 0); | ||
``` | ||
|
||
Derive the private key from the test mnemonic at path `m/44'/60'/0'/1/0`: | ||
|
||
```solidity | ||
string memory mnemonic = "test test test test test test test test test test test junk"; | ||
uint256 privateKey = vm.deriveKey(mnemonic, "m/44'/60'/0'/1/", 0); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
- [`addr`](./addr.md) | ||
- [`sign`](./sign.md) | ||
- [`label`](./label.md) | ||
- [`deriveKey`](./derive-key.md) |