From fa6f5957362118c37bef044b74a1ae7c883c538c Mon Sep 17 00:00:00 2001 From: emochka2007 Date: Sat, 25 May 2024 01:45:12 +0300 Subject: [PATCH] seed phrase --- chain-api/src/ethereum/ethereum.controller.ts | 5 +++++ chain-api/src/ethereum/ethereum.service.ts | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/chain-api/src/ethereum/ethereum.controller.ts b/chain-api/src/ethereum/ethereum.controller.ts index d535715..e0c4ae2 100644 --- a/chain-api/src/ethereum/ethereum.controller.ts +++ b/chain-api/src/ethereum/ethereum.controller.ts @@ -9,4 +9,9 @@ export class EthereumController { async getAddressFromPrivateKey(@Param('privateKey') privateKey: string) { return this.ethereumService.getAddressFromPrivateKey(privateKey); } + + @Get('/address-from-seed/:seedPhrase') + async getAddressFromSeedPhrase(@Param('seedPhrase') seedPhrase: string) { + return this.ethereumService.getAddressFromSeedPhrase(seedPhrase); + } } diff --git a/chain-api/src/ethereum/ethereum.service.ts b/chain-api/src/ethereum/ethereum.service.ts index 341ab32..fd30cd6 100644 --- a/chain-api/src/ethereum/ethereum.service.ts +++ b/chain-api/src/ethereum/ethereum.service.ts @@ -7,4 +7,8 @@ export class EthereumService { const wallet = new ethers.Wallet(privateKey); return wallet.address; } + async getAddressFromSeedPhrase(seedPhrase: string) { + const wallet = ethers.Wallet.fromPhrase(seedPhrase); + return wallet.address; + } }