Ethscriptions commited on
Commit
f1fd83c
·
1 Parent(s): 2e9b9aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -47,10 +47,11 @@ def sha256(input_string):
47
 
48
  # 发送自己到自己 0ETH 的交易
49
  def send_transaction(w3, account_address, private_key, chain_id, gas_price, input_data, current_nonce):
 
50
  # 设置交易的相关信息
51
  tx = {
52
  'chainId': chain_id, # 网络 ID
53
- # 'gas': 25000, # 原始的固定 gas
54
  'gasPrice': gas_price, # gas 的价格
55
  'nonce': current_nonce,
56
  'to': account_address, # 接收地址为自己
@@ -58,15 +59,12 @@ def send_transaction(w3, account_address, private_key, chain_id, gas_price, inpu
58
  'data': text_to_hex(input_data), # 铭文内容
59
  }
60
 
61
- # 估算交易所需的 gas
62
- tx['gas'] = w3.eth.estimate_gas(tx)
63
-
64
  # 用私钥签名这个交易
65
  signed_tx = w3.eth.account.sign_transaction(tx, private_key)
66
  # 发送签名后的交易并获取交易哈希
67
  tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
68
  # 打印结果信息
69
- st.toast(f'{input_data}', icon='✅')
70
  # 返回铭文还有交易哈希
71
  return input_data, tx_hash.hex()
72
 
@@ -111,7 +109,7 @@ if approved_use:
111
  # 这里配置 Ethereum PRC URL,如果你没有,请到 infura.io 或者 alchemy.com 申请一个免费的 API
112
  token_eth_prc_url = st.text_input(
113
  f'**Polygon PRC 链接**:选填,你可以去 [infura.io](https://app.infura.io/) 或者 [alchemy.com](https://alchemy.com/) 免费申请一个',
114
- f'https://polygon-mainnet.g.alchemy.com/v2/UNAiPmma0H0vPaeimRGnIYJmJu0iAHkr')
115
  w3 = Web3(Web3.HTTPProvider(f'{token_eth_prc_url}'))
116
 
117
  # 初始化当前账户索引为 0
@@ -168,7 +166,7 @@ if approved_use:
168
  current_account_index = (current_account_index + 1) % len(accounts)
169
  # 暂停 3 秒
170
  if sleep_3s:
171
- time.sleep(3) # 暂停三秒
172
  st.toast(f'所有任务已经完成。', icon='🎉')
173
  # 庆祝动画
174
  st.balloons()
@@ -176,4 +174,3 @@ if approved_use:
176
  st.code('\n'.join(transaction_results))
177
  else:
178
  st.error('# 阅读并打勾 ✅ 后方可使用。')
179
-
 
47
 
48
  # 发送自己到自己 0ETH 的交易
49
  def send_transaction(w3, account_address, private_key, chain_id, gas_price, input_data, current_nonce):
50
+
51
  # 设置交易的相关信息
52
  tx = {
53
  'chainId': chain_id, # 网络 ID
54
+ 'gas': 25000, # 如果交易 gas 过低,可适当调高
55
  'gasPrice': gas_price, # gas 的价格
56
  'nonce': current_nonce,
57
  'to': account_address, # 接收地址为自己
 
59
  'data': text_to_hex(input_data), # 铭文内容
60
  }
61
 
 
 
 
62
  # 用私钥签名这个交易
63
  signed_tx = w3.eth.account.sign_transaction(tx, private_key)
64
  # 发送签名后的交易并获取交易哈希
65
  tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
66
  # 打印结果信息
67
+ st.toast(f'{the_id}', icon='✅')
68
  # 返回铭文还有交易哈希
69
  return input_data, tx_hash.hex()
70
 
 
109
  # 这里配置 Ethereum PRC URL,如果你没有,请到 infura.io 或者 alchemy.com 申请一个免费的 API
110
  token_eth_prc_url = st.text_input(
111
  f'**Polygon PRC 链接**:选填,你可以去 [infura.io](https://app.infura.io/) 或者 [alchemy.com](https://alchemy.com/) 免费申请一个',
112
+ f'https://polygon-mainnet.infura.io/v3/ae62dc706386486189a47641e73b43c0')
113
  w3 = Web3(Web3.HTTPProvider(f'{token_eth_prc_url}'))
114
 
115
  # 初始化当前账户索引为 0
 
166
  current_account_index = (current_account_index + 1) % len(accounts)
167
  # 暂停 3 秒
168
  if sleep_3s:
169
+ time.sleep(0.5) # 暂停三秒
170
  st.toast(f'所有任务已经完成。', icon='🎉')
171
  # 庆祝动画
172
  st.balloons()
 
174
  st.code('\n'.join(transaction_results))
175
  else:
176
  st.error('# 阅读并打勾 ✅ 后方可使用。')