How to use the merkle-patricia-tree/secure function in merkle-patricia-tree

To help you get started, we’ve selected a few merkle-patricia-tree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nomiclabs / buidler / packages / buidler-core / src / internal / buidler-evm / provider / node.ts View on Github external
public static async create(
    hardfork: string,
    networkName: string,
    chainId: number,
    networkId: number,
    blockGasLimit: number,
    throwOnTransactionFailures: boolean,
    throwOnCallFailures: boolean,
    genesisAccounts: GenesisAccount[] = [],
    stackTracesOptions?: SolidityTracerOptions
  ): Promise<[Common, BuidlerNode]> {
    const stateTrie = new Trie();
    const putIntoStateTrie = promisify(stateTrie.put.bind(stateTrie));
    for (const acc of genesisAccounts) {
      let balance: BN;

      if (
        typeof acc.balance === "string" &&
        acc.balance.toLowerCase().startsWith("0x")
      ) {
        balance = new BN(toBuffer(acc.balance));
      } else {
        balance = new BN(acc.balance);
      }

      const account = new Account({ balance });
      const pk = toBuffer(acc.privateKey);
      const address = privateToAddress(pk);