web3js – How to Define Private Key Variable Using Config Library in Python for PancakeSwap

pancakeswappythontokensweb3.pyweb3js

i am trying to interpret a code for buying tokens through Pancakeswap using Python.
I got stuck at the Private Key where the variable is "config.private" in the code. But I have seen other similar codes where they put private_key = "xxxxxxxxxxxxxxxxxxxxx".

The explanation I saw in the video where you put the variable like "config.private" is to prevent them from seeing your private key and put it as an imported script from another file.

I don't know the ".private" module from the config library. I would like to know the process you did in the other file and how you linked it to the line of code in the working file.

signed_txn = web3.eth.account.sign_transaction(pancakeswap2_txn, private_key=config.private)

Best Answer

Create a config.py in the same directory with the file you want to import config, put to this file

private="xxxxx"

In the file you want to import

import config
...
print(config.private) // xxxxx

And add config.py to .gitignore file

Related Topic