#!/usr/bin/env python3 import os, random, json import ipfshttpclient from web3 import Web3 from pydub.generators import Sine from pydub import AudioSegment import mido RPC_URL = "https://berachain-rpc.publicnode.com" PRIVATE_KEY = os.environ.get("DEPLOYER_PK") # your wallet PK w3 = Web3(Web3.HTTPProvider(RPC_URL)) acct = w3.eth.account.from_key(PRIVATE_KEY) # Replace with your deployed contract details FART_CONTRACT = "0xYourContractAddress" FART_ABI = json.load(open("FartSymphonyABI.json")) contract = w3.eth.contract(address=FART_CONTRACT, abi=FART_ABI) ipfs = ipfshttpclient.connect() def generate_fart(): tone = Sine(55).to_audio_segment(duration=500).fade_in(50).fade_out(150) noise = Sine(30).to_audio_segment(duration=400).fade_in(30).fade_out(100) fart = tone.overlay(noise) fart.export("fart.wav", format="wav") return ipfs.add("fart.wav")["Hash"] def generate_midi(): mid = mido.MidiFile() track = mido.MidiTrack() mid.tracks.append(track) for i in range(5): note = random.randint(40, 70) track.append(mido.Message("note_on", note=note, velocity=64, time=200)) track.append(mido.Message("note_off", note=note, velocity=64, time=400)) mid.save("fart.mid") return ipfs.add("fart.mid")["Hash"] def mint_signal(): desc = random.choice([ "Velvety bloom with earthy undertones", "Sharp citrus alpha crackle", "Smoky oak trail of liquidity" ]) keyword = desc.split()[0] soundHash = generate_fart() midiHash = generate_midi() nonce = w3.eth.get_transaction_count(acct.address) txn = contract.functions.mintSignal(keyword, desc, soundHash, midiHash).build_transaction({ "from": acct.address, "nonce": nonce, "gas": 600000, "gasPrice": w3.eth.gas_price }) signed = w3.eth.account.sign_transaction(txn, PRIVATE_KEY) tx_hash = w3.eth.send_raw_transaction(signed.rawTransaction) print(f"🚀 Minted new Fart NFT {desc} | TX {tx_hash.hex()}") # ---- Instead of timer, call mint when alpha signal detected if __name__ == "__main__": # Example: one mint now mint_signal()