I want to generate an kusama address. The substrate-interface can make it?Or how to generate an ss58 format address by python
1 Answer
You need to provide the SS58 prefix to the create_from_mnemonic
function to make it generate a Kusama address as opposed to a generic Substrate address:
from substrateinterface import Keypair
# 2 for Kusama.
prefix = 2
# If you want to use a random mnemonic:
mnemonic = Keypair.generate_mnemonic()
# ... or use a specific mnemonic:
mnemonic = 'episode together nose spoon dose oil faculty zoo ankle evoke admit walnut'
keypair = Keypair.create_from_mnemonic(mnemonic, ss58_format=prefix)
# Prints JHXFqYWQFFr5RkHVzviRiKhY7tutyGcYQb6kUyoScSir862
print(keypair.ss58_address)
Kusama has the prefix 2, you can see all of them in the ss58-registry.
-
Also you can add
Keypair.generate_mnemonic()
to the anwser above to generate a new address– ArjanSep 8, 2022 at 18:26 -