Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #622 from kjeom/web3py-v3keystore-load-example
Browse files Browse the repository at this point in the history
web3py-ext v3 keystore load example
  • Loading branch information
jack authored May 29, 2024
2 parents a624bb3 + 3bd4e3f commit ab9a1a6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
File renamed without changes.
30 changes: 30 additions & 0 deletions web3py-ext/web3py_ext/example/account/v3_keystore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from web3py_ext import extend
from eth_account import Account

v3_keystore_str = '''{
"address": "029e786304c1531af3ac7db24a02448e543a099e",
"id": "9d492c95-b9e3-42e3-af73-5c77e932208d",
"version": 3,
"crypto": {
"cipher": "aes-128-ctr",
"cipherparams": {"iv": "bfcb88a1501e2bb1e6694c03da18953d"},
"ciphertext": "076510b4e25d5cfc31239bffcad6036fe543cbbb04b9f3ec719bf4f61b58fc05",
"kdf": "scrypt",
"kdfparams": {
"salt": "79124f05995aae98b3088d8365f59a6dfadd1c9ed249abae3c07733f4cbbee53",
"n": 131072,
"dklen": 32,
"p": 1,
"r": 8
},
"mac": "d70f83824c2c30dc5cd3a244d87147b6aa713a6000165789a82a467651284ac7"
}
}'''

with open('keystore', 'w') as f:
f.write(v3_keystore_str)

with open('keystore') as f:
pk = Account.decrypt(f.read(), 'password')
acc = Account.from_key(pk)
print(acc.address, acc.key.hex())

0 comments on commit ab9a1a6

Please sign in to comment.