├── wallet_generator.py ├── EVM_inscription.py ├── README.md └── batch_inscription.py /wallet_generator.py: -------------------------------------------------------------------------------- 1 | from web3 import Web3 2 | import os 3 | 4 | def generate_wallets(num_wallets, file_path): 5 | # Check if the file already exists 6 | if os.path.exists(file_path): 7 | print(f"File '{file_path}' already exists. No wallets generated.") 8 | return 9 | 10 | w3 = Web3() 11 | 12 | with open(file_path, 'w') as file: 13 | for _ in range(num_wallets): 14 | # Generate a new account 15 | account = w3.eth.account.create() 16 | address = account.address 17 | private_key = account._private_key.hex() 18 | 19 | # Write the address and private key to the file 20 | file.write(f'Address: {address}\nPrivate Key: {private_key}\n\n') 21 | print(f'{num_wallets_to_generate} wallets have been generated and saved to {output_file_path}') 22 | 23 | if __name__ == "__main__": 24 | # Change this to the number of wallets you want to generate 25 | num_wallets_to_generate = 10 26 | 27 | output_file_path = 'wallets.txt' # The path to the output file 28 | generate_wallets(num_wallets_to_generate, output_file_path) -------------------------------------------------------------------------------- /EVM_inscription.py: -------------------------------------------------------------------------------- 1 | from web3 import Web3 2 | from hexbytes import HexBytes 3 | 4 | # Enter your private key here 5 | private_key = '' 6 | 7 | # Chose chain, uncomment the target chain below 8 | # rpc_link = 'https://eth-mainnet.g.alchemy.com/v2/Q1q4tFJe4hUf4iOJWM7SMW7Dtn2iwCvP'# ETH 9 | #rpc_link = 'https://bsc-dataseed3.binance.org/' #BSC 10 | rpc_link = 'https://polygon-mainnet.g.alchemy.com/v2/hrLvjZ3LRWuPItG9LuYsZQcRU_XtvRmX' # polygon 11 | # rpc_link = 'https://oktc-mainnet.public.blastapi.io' #OKT 12 | # rpc_link = 'https://api.avax.network/ext/bc/C/rpc' #AVAX 13 | 14 | # Enter the repeat times of inscriptions 15 | no_to_mint = 3 16 | 17 | # Enter the data to inscribe 18 | # 0x is not required 19 | hex_data = "93c8ac01bae28307f2c017c134998e92951a66c80c1ad30f8125390c46476eaa" 20 | 21 | # Enter the price factor to the current gas fee 22 | # 1 means to use the current gas fee 23 | price_factor = 1 24 | 25 | w3 = Web3(Web3.HTTPProvider(rpc_link)) 26 | if not w3.is_connected(): 27 | raise ConnectionError("Failed to connect to node") 28 | 29 | for i in range(no_to_mint): 30 | print(f"The inscription being engraved is: {i+1}") 31 | sender_account = w3.eth.account.from_key(private_key) 32 | sender_address = sender_account.address 33 | chain_id = w3.eth.chain_id 34 | gas_price = w3.eth.gas_price 35 | 36 | transaction = { 37 | 'to': sender_address, 38 | 'value': 0, # Value is 0 ETH 39 | 'gas': 100000, 40 | 'gasPrice': int(gas_price*price_factor), 41 | 'nonce': w3.eth.get_transaction_count(sender_address), 42 | 'data': hex_data, 43 | 'chainId': chain_id 44 | } 45 | 46 | signed_txn = w3.eth.account.sign_transaction(transaction, private_key) 47 | txn_hash = w3.eth.send_raw_transaction(signed_txn.rawTransaction) 48 | txn_receipt = w3.eth.wait_for_transaction_receipt(txn_hash) 49 | tx_hash = txn_receipt.transactionHash.hex() 50 | 51 | print(f"The inscription {i+1} is completed, transaction hash is {tx_hash}.") -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EVM Inscription 2 | 3 | ## Overview 4 | `EVM_inscription` is a Python script tailored for the efficient batch creation of inscriptions on Ethereum Virtual Machine (EVM)-compatible blockchains. It streamlines the process of connecting to various blockchain networks and automates the submission of multiple transactions. 5 | 6 | ## Features 7 | - **Multiple Blockchain Support**: Compatible with several EVM blockchains like Ethereum, Binance Smart Chain, and Polygon. 8 | - **Dynamic Configuration**: Customize the number of inscriptions, transaction data, and gas pricing. 9 | - **Secure Private Key Handling**: Ensures the safe usage of your private key without hardcoding it in the script. 10 | - **User-Friendly**: Simple setup and execution process. 11 | 12 | ## Prerequisites 13 | Before using this script, make sure you have Python installed on your system. You can download it from [here](https://www.python.org/downloads/). 14 | 15 | ## Installation 16 | 1. **Install web3.py**: This script depends on the `web3.py` package. Install it by running the following command in your terminal: 17 | ``` 18 | pip install web3 19 | ``` 20 | 2. **Clone the Repository** (Optional): If the script is hosted in a repository, you can clone it using: 21 | ``` 22 | git clone https://github.com/hosir-web3/EVM_inscription.git 23 | ``` 24 | 25 | ## Setup 26 | 1. **Private Key**: For security reasons, do not hardcode your private key in the script. Instead, use an environment variable or a secure key management system. 27 | 2. **RPC URL**: Choose the appropriate RPC URL for the blockchain you intend to interact with. 28 | 3. **Configuration**: 29 | - `no_to_mint`: Set the number of inscriptions you wish to create. 30 | - `hex_data`: Provide the hexadecimal data for the inscription. 31 | - `price_factor`: Adjust the gas price factor according to network conditions. 32 | 33 | ## Usage 34 | 1. Open the script and enter the required configuration parameters. 35 | 2. Run the script from your terminal: 36 | ``` 37 | python evm_inscription.py 38 | ``` 39 | 40 | ## Useful Link 41 | - More public RPC link can be found at [ChainList](https://chainlist.org/). 42 | - A tool to convert data to hex data at [Ethscriber](https://ethscriber.xyz/). 43 | - Inscription monitor at [EVM.ink](https://evm.ink/). 44 | 45 | ## Important Notes 46 | - Always ensure that your private key is stored securely and never exposed in the script or its logs. 47 | - Be aware of the gas fees and network conditions of the blockchain you are interacting with to avoid unexpected costs. 48 | -------------------------------------------------------------------------------- /batch_inscription.py: -------------------------------------------------------------------------------- 1 | from web3 import Web3 2 | from hexbytes import HexBytes 3 | import time 4 | 5 | # Enter your private key here, 0x is not required 6 | private_key = '' 7 | 8 | # Chose chain, uncomment the target chain below 9 | # rpc_link = 'https://eth-mainnet.g.alchemy.com/v2/Q1q4tFJe4hUf4iOJWM7SMW7Dtn2iwCvP'# ETH 10 | # rpc_link = 'https://bsc-dataseed3.binance.org/' #BSC 11 | # rpc_link = 'https://oktc-mainnet.public.blastapi.io' #OKT 12 | # rpc_link = 'https://api.avax.network/ext/bc/C/rpc' #AVAX 13 | rpc_link = 'https://rpc-1.bevm.io' # BEVM 14 | 15 | # Enter the repeat times of inscriptions 16 | no_to_mint = 10 # number of inscription to send for each iteration 17 | repeat_times = 5 # number of iterations 18 | 19 | # Enter the data to inscribe 20 | # 0x is not required 21 | hex_data = "" 22 | 23 | # Enter the price factor to the current gas fee 24 | # 1 means to use the current gas fee 25 | # it should be greater than 1 26 | price_factor = 1.1 27 | 28 | # connect to the node 29 | w3 = Web3(Web3.HTTPProvider(rpc_link)) 30 | if not w3.is_connected(): 31 | raise ConnectionError("Failed to connect to node") 32 | 33 | # initialization 34 | sender_account = w3.eth.account.from_key(private_key) 35 | sender_address = sender_account.address 36 | chain_id = w3.eth.chain_id 37 | 38 | # last nonce of this account, used to compute the transaction count 39 | initial_nonce = w3.eth.get_transaction_count(sender_address) 40 | print(f"starting nonce is {initial_nonce}") 41 | 42 | for i in range(repeat_times): 43 | try: 44 | print(f"Repeating time: {i+1}") 45 | gas_price = w3.eth.gas_price # get the recent price 46 | start_nonce = w3.eth.get_transaction_count(sender_address) # last nonce of this account 47 | if i != 0 and start_nonce != last_nonce: 48 | # if it is not the first time, it is possible the transaction of last time is not packaged 49 | # the price should not be lower than the last time 50 | gas_price = max(int(gas_price*price_factor), int(last_gas_price*price_factor)) 51 | 52 | print(f"{start_nonce - initial_nonce} inscriptions have been inscribed.") 53 | 54 | # send transaction 55 | for j in range(no_to_mint): 56 | nonce = start_nonce + j 57 | transaction = { 58 | 'to': sender_address, 59 | 'value': 0, 60 | 'gas': 23000, 61 | 'gasPrice': gas_price, 62 | 'nonce': nonce, 63 | 'data': hex_data, 64 | 'chainId': chain_id 65 | } 66 | 67 | signed_txn = w3.eth.account.sign_transaction(transaction, private_key) 68 | txn_hash = w3.eth.send_raw_transaction(signed_txn.rawTransaction) 69 | print(f"txn_hash: {txn_hash.hex()}, nonce: {nonce}") 70 | except Exception as e: 71 | print(e) 72 | # get information for next iteration 73 | last_nonce = start_nonce + no_to_mint 74 | last_block = w3.eth.get_block_number() 75 | last_gas_price = gas_price 76 | while (last_block == w3.eth.get_block_number()): 77 | # waiting for a new block to be packaged 78 | time.sleep(3) --------------------------------------------------------------------------------