Skip to content

Commit

Permalink
vm: fix genesis state example + make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Aug 13, 2024
1 parent 67b8fcb commit 4dce079
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/vm/examples/run-blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ async function putBlocks(blockchain: Blockchain, common: Common, data: typeof te
}
}

main()
void main()
2 changes: 1 addition & 1 deletion packages/vm/examples/run-solidity-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,4 @@ async function main() {
console.log('Everything ran correctly!')
}

main()
void main()
11 changes: 7 additions & 4 deletions packages/vm/examples/vmWithGenesisState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createBlockchain } from '@ethereumjs/blockchain'
import { Chain } from '@ethereumjs/common'
import { getGenesis } from '@ethereumjs/genesis'
import { createAddressFromString } from '@ethereumjs/util'
Expand All @@ -7,12 +6,16 @@ import { VM } from '@ethereumjs/vm'
const main = async () => {
const genesisState = getGenesis(Chain.Mainnet)

const blockchain = await createBlockchain({ genesisState })
const vm = await VM.create({ blockchain })
const vm = await VM.create()
await vm.stateManager.generateCanonicalGenesis!(genesisState)
const account = await vm.stateManager.getAccount(
createAddressFromString('0x000d836201318ec6899a67540690382780743280'),
)
console.log(account)

if (account === undefined) {
throw new Error('Account does not exist: failed to import genesis state')
}

console.log(
`This balance for account 0x000d836201318ec6899a67540690382780743280 in this chain's genesis state is ${Number(
account?.balance,
Expand Down

0 comments on commit 4dce079

Please sign in to comment.