3

I'd like to use Substrate Frontier as a private blockchain for my current project. I have set up a project using a frontier-template-node build and I am now trying to adjust its settings.

I am currently stuck with issues with accounts I generated:

  • In the chain specification file (customSpec.yml), I replaced the sudo account id of Alice by an account id I created. This account is not able to deploy a contract but Alice is still authorized to do it. I get the error Returned error: insufficient funds for gas * price + value while the substrate and EVM balances of the account seems well funded.
  • All the user accounts I created are not able to perform a transaction. I get the same error Returned error: insufficient funds for gas * price + value even with a balance of 1,000,000,000 ETH

Here is a sample call I execute on my code:

    // Load contract
    const contract = new web3.eth.Contract(contractAbi, contractAddress, {
      from: signerAddress,
      gasPrice: '0x3B9ACA00',
    });

    // Prepare method transaction
    const encodedMethod = await contract.methods.transfer([userAddress, 100]).encodeABI();

    // Sign transaction
    const methodTx = await web3.eth.accounts.signTransaction(
      {
        from: signerAddress,
        to: contractAddress,
        data: encodedMethod,
        gasPrice: '0x3B9ACA00',
        gas: '0x1000000',
      },
      signerPrivateKey,
    );

    // Send transaction
    const txReceipt = await web3.eth.sendSignedTransaction(methodTx.rawTransaction);

Could you give me some advices to fix this issue?

9
  • Not super familiar with Frontier, but in your chain spec, when substituting the account for SUDO, have you also include that account in he vec of pre-funded accounts ? github.com/substrate-developer-hub/frontier-node-template/blob/… Commented Jan 5, 2023 at 11:38
  • So, for what I can see this error happens either when the gas price is too low, the accounts don't have enough funds, or when there is an invalid payment input Commented Jan 5, 2023 at 11:58
  • @AlejandroMartínez Yes I added this account to the pre-funded accounts list and its balance is very high (0xffffffffffffffffffffffffffffffff). The account has been created with the command line ./target/release/frontier-template-node key generate with a password and I wonder if it could be the reason to the problem. It looks like the privateKey I passed to the transaction is not properly linked to the account. Could it be the problem and i there a way to give the password in order to fix this issue? Commented Jan 5, 2023 at 13:05
  • Have you also changed the accounts set for the EVM compatibilty ? Commented Jan 5, 2023 at 17:24
  • @AlejandroMartínez I have changed accounts directly in the json generated by the command ./target/release/frontier-template-node build-spec --disable-default-bootnode --chain local > customSpec.json in both sections balances and evm.accounts. Should I edit the chain_spec.rs before generating the json? Commented Jan 6, 2023 at 8:24

1 Answer 1

0

I finally solved this issue.

The Public key (hex) returned by the substrate command line ./target/release/frontier-template-node key generate --scheme Sr25519 does not worked for the evm accounts configuration in customSpec.yml.

I generated the right public key by calling the privateKeyToAccount function of Web3.js:

import Web3Accounts from 'web3-eth-accounts';
const ethPublicKey = new Web3Accounts().privateKeyToAccount(privateKey).address;

Then the eth balance is correctly assign to my sudo account at the initialization of my local blockchain and I can use it to make transaction and fund other accounts.

Not the answer you're looking for? Browse other questions tagged or ask your own question.