I'm working on a project using an EVM-compatible Substrate blockchain. I am encountering problems when trying to call functions on this Substrate instance.
Here's the function used to sign and send transactions to Substrate pallets:
async _signAndSendTransaction(account, tx) {
try {
const { cryptoWaitReady, mnemonicGenerate } = require('@polkadot/util-crypto');
const { Keyring } = require('@polkadot/keyring');
await cryptoWaitReady();
const keyring = new Keyring({ type: 'sr25519' });
const senderAccount = keyring.addFromUri(account.mnemonic);
console.log(senderAccount.address)
// const nonce = await this.api.rpc.system.accountNextIndex(account.address);
const signedTx = await tx.signAsync(senderAccount);
const hash = await signedTx.send();
return hash.toHex();
} catch (error) {
console.log(error.message)
}
}
For wallet connection, I'm utilizing Metamask, and the EVM-based address that I use to call the functions is 0x6C45Ada1e3bE236D2667b4f2828888991263A4dD
.
However, when I log the following lines:
const senderAccount = keyring.addFromUri(account.mnemonic);
console.log(senderAccount.address)
I get a different address: 5E4bnwDsLFpe28WtyYVva5joGxhDUQ7M1Gzd4ndWCY52R21e
.
Finally, I encounter this error message:
2023-07-02 00:15:42 RPC-CORE: submitExtrinsic(extrinsic: Extrinsic): Hash:: 1010: Invalid Transaction: Inability to pay some fees , e.g. account balance too low 1010: Invalid Transaction: Inability to pay some fees , e.g. account balance too low
I'd appreciate any guidance on how I might solve this issue. Thanks in advance for your help.