Skip to content

Instantly share code, notes, and snippets.

@karlb
Last active January 9, 2024 12:39
Show Gist options
  • Save karlb/10752228f093c2c465d5dd1b09cafb49 to your computer and use it in GitHub Desktop.
Save karlb/10752228f093c2c465d5dd1b09cafb49 to your computer and use it in GitHub Desktop.
Celo notes
import { createPublicClient, createWalletClient, http, defineChain } from 'viem'
import { celoAlfajores } from 'viem/chains'
import { privateKeyToAccount } from 'viem/accounts'
const devChain = defineChain({
...celoAlfajores,
id: 1337,
name: 'local dev chain',
network: 'dev',
rpcUrls: {
default: {
http: ['http://127.0.0.1:8545'],
},
},
})
const account = privateKeyToAccount('0x2771aff413cac48d9f8c114fabddd9195a2129f3c2c436caa07e27bb7f58ead5')
const walletClient = createWalletClient({
account,
chain: devChain,
transport: http(),
})
const request = await walletClient.prepareTransactionRequest({
account,
to: '0x00000000000000000000000000000000DeaDBeef',
value: 1,
feeCurrency: '0x000000000000000000000000000000000000ce16',
})
const signature = await walletClient.signTransaction(request)
const hash = await walletClient.sendRawTransaction({ serializedTransaction: signature })
console.log(hash)

Run geth in dev mode with a --datadir and --snapshot

geth --dev --http --http.api eth,web3,net --datadir dev-chain --snapshot

Create 128 transactions

for i in (seq 130); cast send --private-key $ACC_PRIVKEY --value 0.001ether 0x000000000000000000000000000000000000dEaD; end

Stop geth and execute pruning command

geth --datadir dev-chain snapshot prune-state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment