I’m coding a script in python that can contain a huge list of data “on the fly” since they are sequenced one at a time, and I came across am issue. The index can only be accessed by specifying the number of the index that you want to go to but the thing is there’s so much data that I don’t know where exactly it is in the index.
I want to make the last 40 characters of what is inside the index the name of the index so I can access all indexes by typing in the last 40 characters of them which I know. My code so far is:
from eth_keys import keys
def generate_key_pair(index):
# Generate the private key from the index
private_key = hex(index)[2:].zfill(64) # Convert index to hexadecimal
# Generate the corresponding wallet address
private_key_bytes = bytes.fromhex(private_key)
wallet_address = keys.PrivateKey(private_key_bytes).public_key.to_checksum_address()
return private_key, wallet_address
def combine_strings(private_key, wallet_address):
# Combine private key and wallet address into a single string
combined_string = private_key + wallet_address
return combined_string
def main():
index = 1
private_key, wallet_address = generate_key_pair(index)
combined_string = combine_strings(private_key, wallet_address)
print("Combined string:", combined_string)
if __name__ == "__main__":
main()
This code is used to combine wallet and private keys for ethereum which I need for my business in order to allow users to store their data. There will be many users so we create ethereum wallets for them and store their data in there. Can somebody show me how to access another index by using the last 40 characters of the combined private key and wallet address which is inside each separate index?