I am running the Frontier-Node-Template and using the library Web3JS to generate EVM transactions following the Moonbeam guide.
const Web3 = require('web3');
const web3 = new Web3('ws://127.0.0.1:9944');
I am generating my Account using:
./target/release/frontier-template-node key generate
The account generated:
Secret phrase: worth wrestle meat ecology merry ginger online glad soda usage peasant lava
Network ID: substrate
Secret seed: 0x8e940c2a136dadf87c3b4b408866ff5fb1cbb64893a933493341c5e400a81690
Public key (hex): 0x381faf1906bf0ea763e7e25f110b26b880680d55bed21f52b76d9d5973fcee6e
Account ID: 0x381faf1906bf0ea763e7e25f110b26b880680d55bed21f52b76d9d5973fcee6e
Public key (SS58): 5DLHx6nDCn9EiYHryuyELhvsDKBmZGwLZthSdD3cshjAzusN
SS58 Address: 5DLHx6nDCn9EiYHryuyELhvsDKBmZGwLZthSdD3cshjAzusN
Following the tutorial from the Substrate Docs I calculated the Ethereum Address for my account, basically truncating the Public key (hex) value above: 0x381faf1906bf0ea763e7e25f110b26b880680d55
With an Account that has funds, I sent some funds into this account. I check the Balance and works fine:
const balanceTo = web3.utils.fromWei(await web3.eth.getBalance("0x381faf1906bf0ea763e7e25f110b26b880680d55"), 'ether');
console.log(`The balance of 0x381faf1906bf0ea763e7e25f110b26b880680d55 is: ${balanceTo} ETH`);
The balance of 0x381faf1906bf0ea763e7e25f110b26b880680d55 is: 2.4999999999999995 ETH
Now I want to send funds from this account, and my question is how I calculate the ETH private key of this account?
I have tried with the Secret seed and to generate an Ethereum wallet from the mnemonic phrase:
const { Wallet } = require('ethers');
const myWalletMnemonic = "worth wrestle meat ecology merry ginger online glad soda usage peasant lava";
const wallet = Wallet.fromMnemonic(myWalletMnemonic);
But when sending the transfer:
const createTransaction = await web3.eth.accounts.signTransaction(
{
gas: 21000,
to: accountFrom.address,
value: web3.utils.toWei('1', 'ether'),
},
wallet.privateKey
);
const createReceipt = await web3.eth.sendSignedTransaction(createTransaction.rawTransaction);
I am getting an error:
Error: Returned error: submit transaction to pool failed: Pool(InvalidTransaction(InvalidTransaction::Payment))