這篇文章旨在作為快速參考與展示。要更多完整的資訊,請見 John Gruber 原本的規格與 Github 偏好的 Markdown(Github-flavored Markdown,簡寫為GFM)資訊頁。
如果你正在找 Markdown Here 的小抄(Cheatsheet),這裡也有一篇。你也可以看看更多 Markdown 的工具。
譯註:可以參考這份中文版文件,有更詳盡的 Markdown 語法說明;如果需要可以練習的線上編輯器,可以試試看HackMD。
## Indeed https://tw.indeed.com/cmp/Ikala-愛卡拉/salaries | |
- 數據分析 4 | |
- 低 30,690元 平均 47,246元 高 72,732元 | |
- 客戶經理 7 | |
- 低 20,000元 平均 40,000元 高 60,000元 | |
- 業務 11 | |
- 低 19,000元 平均 37,976元 高 58,000元 | |
- 行銷 5 | |
- 低 20,000元 平均 40,000元 高 60,000元 | |
- 企劃 2 |
import streamlit as st | |
import pandas as pd | |
from bf import BloomFilter | |
from web.tools import deploy_contract, store_data, get_data | |
col1, col2, col3 = st.columns(3) | |
with col1: | |
st.header('deploy') | |
def deploy(): |
def get_data(n, p, contract_address, x): | |
with open('ethereum/build/abi.json', 'r') as json_file: | |
abi = json.load(json_file) | |
bf = BloomFilter(n, p) | |
My_Contract = w3.eth.contract( | |
address=contract_address, | |
abi=abi | |
) | |
bytes, pad = My_Contract.functions.retrieve().call() | |
b_arr = bitarray() |
def store_data(n, p, contract_address, data): | |
with open('ethereum/build/abi.json', 'r') as json_file: | |
abi = json.load(json_file) | |
bf = BloomFilter(n, p) | |
for idx, row in data.iterrows(): | |
bf.add(row[0]) | |
My_Contract = w3.eth.contract( | |
address=contract_address, | |
abi=abi | |
) |
def deploy_contract(): | |
with open('ethereum/contracts/my_contract.sol', 'r') as file: | |
contract_file = file.read() | |
compiled_sol = compile_source(contract_file, output_values=['abi', 'bin']) | |
contract_id, contract_interface = compiled_sol.popitem() | |
My_Contract = w3.eth.contract(abi=contract_interface['abi'], bytecode=contract_interface['bin']) | |
with open('ethereum/build/abi.json', 'w+') as json_file: | |
json.dump(json.dumps(contract_interface['abi']), json_file) | |
txn = My_Contract.constructor().buildTransaction({"nonce":w3.eth.getTransactionCount(myAccount.address)}) | |
signed_txn = myAccount.sign_transaction(txn) |
import os | |
from dotenv import load_dotenv | |
from web3 import Web3 | |
from web3.middleware import geth_poa_middleware | |
load_dotenv() | |
w3 = Web3(Web3.HTTPProvider(os.getenv('PROVIDER_URL'))) | |
w3.middleware_onion.inject(geth_poa_middleware, layer=0) | |
myAccount = w3.eth.account.privateKeyToAccount(os.getenv('KEY')) |
KEY="{Enter your private key}" | |
PROVIDER_URL="https://rinkeby.infura.io/v3/{Enter your infura key}" |
import hashlib | |
import math | |
import mmh3 | |
from bitarray import bitarray | |
class BloomFilter: | |
def __init__(self, n=20, p=0.05): | |
self.n = n # number of elements | |
self.p = p # False positive | |
self.bit_size = self.get_size(n, p) # number of bits m |
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract Storage { | |
bytes bf_result; | |
uint8 unused_padding; | |
address public manager; | |
這篇文章旨在作為快速參考與展示。要更多完整的資訊,請見 John Gruber 原本的規格與 Github 偏好的 Markdown(Github-flavored Markdown,簡寫為GFM)資訊頁。
如果你正在找 Markdown Here 的小抄(Cheatsheet),這裡也有一篇。你也可以看看更多 Markdown 的工具。
譯註:可以參考這份中文版文件,有更詳盡的 Markdown 語法說明;如果需要可以練習的線上編輯器,可以試試看HackMD。