Skip to content

Commit 211f92d

Browse files
author
AI Deployer
committed
Update Dream-mind-lucid ecosystem: Add rebate checking, deployment scripts, and configuration updates
1 parent a10b0ea commit 211f92d

27 files changed

+2956
-2
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# Legacy SKALE Configuration (maintained for backward compatibility)
1+
# Legacy SKALE Configuration (maintained for backward compatibility)
22
INFURA_PROJECT_ID=your-infura-api-key
33
BICONOMY_API_KEY=your-biconomy-api-key
44
SKALE_CHAIN_ID=2046399126
55
FORWARDER_ADDRESS=0xyour-biconomy-forwarder
6+
DEPLOYER_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
67

78
# Solana Configuration
89
SOLANA_RPC_URL=https://mainnet.helius-rpc.com/?api-key=16b9324a-5b8c-47b9-9b02-6efa868958e5

dream-deploy/deploy.py

1.02 KB
Binary file not shown.

dream-deploy/deploy_program.py

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
from web3 import Web3
2+
from eth_account import Account
3+
from solcx import compile_standard, install_solc
4+
import json
5+
import os
6+
7+
# Connect to Calypso Mainnet
8+
RPC_URL = "https://mainnet.skalenodes.com/v1/honorable-steel-rasalhague"
9+
CHAIN_ID = 1564830818
10+
11+
print("Connecting to SKALE Calypso...")
12+
w3 = Web3(Web3.HTTPProvider(RPC_URL))
13+
assert w3.is_connected(), "Failed to connect to network"
14+
print("Connected successfully")
15+
16+
# Account setup
17+
private_key = "1c734d612698d2f21bc54a6ed073f7cfa6920d02f346a7f15c7f0c5310cc0108"
18+
account = Account.from_key(private_key)
19+
print(f"Using account: {account.address}")
20+
21+
# Check balance
22+
balance = w3.eth.get_balance(account.address)
23+
print(f"Balance: {w3.from_wei(balance, \"ether\")} sFUEL")
24+
25+
# Program Contract
26+
contract_source = """
27+
// SPDX-License-Identifier: MIT
28+
pragma solidity ^0.8.20;
29+
30+
contract DreamProgram {
31+
address public owner;
32+
mapping(address => bool) public operators;
33+
mapping(address => uint256) public dreamCount;
34+
uint256 public totalDreams;
35+
36+
event DreamRecorded(address indexed dreamer, string dream, uint256 dreamId);
37+
event OperatorAdded(address indexed operator);
38+
event OperatorRemoved(address indexed operator);
39+
40+
constructor() {
41+
owner = msg.sender;
42+
operators[msg.sender] = true;
43+
}
44+
45+
modifier onlyOwner() {
46+
require(msg.sender == owner, "Not owner");
47+
_;
48+
}
49+
50+
modifier onlyOperator() {
51+
require(operators[msg.sender], "Not operator");
52+
_;
53+
}
54+
55+
function addOperator(address operator) external onlyOwner {
56+
require(operator != address(0), "Zero address");
57+
operators[operator] = true;
58+
emit OperatorAdded(operator);
59+
}
60+
61+
function removeOperator(address operator) external onlyOwner {
62+
require(operator != owner, "Cannot remove owner");
63+
require(operator != address(0), "Zero address");
64+
operators[operator] = false;
65+
emit OperatorRemoved(operator);
66+
}
67+
68+
function recordDream(string calldata dream) external {
69+
uint256 dreamId = totalDreams + 1;
70+
totalDreams = dreamId;
71+
dreamCount[msg.sender]++;
72+
emit DreamRecorded(msg.sender, dream, dreamId);
73+
}
74+
75+
function getDreamerStats(address dreamer) external view returns (uint256) {
76+
return dreamCount[dreamer];
77+
}
78+
79+
function transferOwnership(address newOwner) external onlyOwner {
80+
require(newOwner != address(0), "Zero address");
81+
owner = newOwner;
82+
}
83+
}
84+
"""
85+
86+
print("\nCompiling contract...")
87+
install_solc("0.8.20")
88+
89+
compiled = compile_standard(
90+
{
91+
"language": "Solidity",
92+
"sources": {"DreamProgram.sol": {"content": contract_source}},
93+
"settings": {
94+
"outputSelection": {
95+
"*": {"*": ["abi", "evm.bytecode"]}
96+
},
97+
"optimizer": {
98+
"enabled": True,
99+
"runs": 200
100+
}
101+
}
102+
},
103+
solc_version="0.8.20"
104+
)
105+
106+
# Get bytecode and ABI
107+
contract_interface = compiled["contracts"]["DreamProgram.sol"]["DreamProgram"]
108+
bytecode = contract_interface["evm"]["bytecode"]["object"]
109+
abi = contract_interface["abi"]
110+
111+
# Create contract
112+
Contract = w3.eth.contract(abi=abi, bytecode=bytecode)
113+
114+
# Get nonce
115+
nonce = w3.eth.get_transaction_count(account.address)
116+
117+
print("\nPreparing transaction...")
118+
# Build constructor transaction
119+
constructor_txn = Contract.constructor().build_transaction({
120+
"chainId": CHAIN_ID,
121+
"gas": 500000,
122+
"gasPrice": w3.eth.gas_price,
123+
"nonce": nonce,
124+
})
125+
126+
print("Signing transaction...")
127+
signed_txn = w3.eth.account.sign_transaction(constructor_txn, private_key)
128+
129+
print("Sending transaction...")
130+
tx_hash = w3.eth.send_raw_transaction(signed_txn.rawTransaction)
131+
print(f"Transaction hash: {tx_hash.hex()}")
132+
133+
print("\nWaiting for confirmation...")
134+
tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
135+
contract_address = tx_receipt.contractAddress
136+
print(f"Contract deployed at: {contract_address}")
137+
print(f"Transaction status: {tx_receipt.status}")
138+
print(f"Gas used: {tx_receipt.gasUsed}")
139+
140+
# Verify contract code exists
141+
code = w3.eth.get_code(contract_address)
142+
print(f"\nVerifying deployment:")
143+
print(f"Contract code exists: {len(code) > 0}")
144+
print(f"Code size: {len(code)} bytes")
145+
146+
if len(code) > 0:
147+
print("\nContract deployed successfully!")
148+
149+
# Save deployment info
150+
deployment_info = {
151+
"contract": "DreamProgram",
152+
"address": contract_address,
153+
"network": "SKALE Calypso Mainnet",
154+
"rpc": RPC_URL,
155+
"chainId": CHAIN_ID,
156+
"owner": account.address,
157+
"transactionHash": tx_hash.hex(),
158+
"abi": abi,
159+
"features": {
160+
"dreamRecording": True,
161+
"operatorControl": True,
162+
"dreamStats": True
163+
}
164+
}
165+
166+
with open("dream_program_deployment.json", "w") as f:
167+
json.dump(deployment_info, f, indent=2)
168+
print("Deployment information saved to dream_program_deployment.json")
169+
170+
# Create contract instance
171+
contract = w3.eth.contract(address=contract_address, abi=abi)
172+
173+
# Verify ownership and initial state
174+
owner = contract.functions.owner().call()
175+
is_operator = contract.functions.operators(account.address).call()
176+
total_dreams = contract.functions.totalDreams().call()
177+
178+
print("\nContract verification:")
179+
print(f"Owner address: {owner}")
180+
print(f"Deployer is operator: {is_operator}")
181+
print(f"Total dreams: {total_dreams}")
182+
183+
print("\nContract Usage Instructions:")
184+
print("1. Owner Functions:")
185+
print(" - addOperator(address) - Add new operators")
186+
print(" - removeOperator(address) - Remove operators")
187+
print(" - transferOwnership(address) - Transfer ownership")
188+
print("2. Public Functions:")
189+
print(" - recordDream(string) - Record a new dream")
190+
print(" - getDreamerStats(address) - Get dreamers total dreams")
191+
print("3. View Functions:")
192+
print(" - owner() - Get current owner")
193+
print(" - operators(address) - Check if address is operator")
194+
print(" - dreamCount(address) - Get dream count for address")
195+
print(" - totalDreams() - Get total number of dreams recorded")
196+
else:
197+
print("\nContract deployment failed!")

dream-test/deploy.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
from web3 import Web3
2+
from eth_account import Account
3+
from solcx import compile_standard, install_solc
4+
5+
# Connect to SKALE
6+
w3 = Web3(Web3.HTTPProvider("https://mainnet.skalenodes.com/v1/elated-tan-skat"))
7+
print(f"Connected to SKALE: {w3.is_connected()}")
8+
9+
# Set up account
10+
private_key = "1c734d612698d2f21bc54a6ed073f7cfa6920d02f346a7f15c7f0c5310cc0108"
11+
account = Account.from_key(private_key)
12+
print(f"Account address: {account.address}")
13+
14+
# Get current gas price
15+
gas_price = w3.eth.gas_price
16+
print(f"Current gas price: {w3.from_wei(gas_price, 'gwei')} gwei")
17+
18+
# Install Solidity compiler
19+
print("Installing Solidity compiler...")
20+
install_solc("0.8.20")
21+
22+
# Compile contract
23+
print("Compiling IEMDreams contract...")
24+
contract_source = """
25+
// SPDX-License-Identifier: MIT
26+
pragma solidity ^0.8.20;
27+
28+
contract IEMDreams {
29+
string public name = "IEM Dreams";
30+
uint256 public totalSupply = 777777777 * 10**18;
31+
mapping(address => uint256) public balances;
32+
33+
event DreamRecorded(address indexed dreamer, string dream);
34+
event TokensMinted(address indexed to, uint256 amount);
35+
36+
constructor() {
37+
balances[msg.sender] = totalSupply;
38+
}
39+
40+
function recordDream(string memory dream) public {
41+
require(balances[msg.sender] >= 10 * 10**18, "Not enough DREAM to record");
42+
balances[msg.sender] -= 10 * 10**18;
43+
emit DreamRecorded(msg.sender, dream);
44+
}
45+
46+
function balanceOf(address account) public view returns (uint256) {
47+
return balances[account];
48+
}
49+
}
50+
"""
51+
52+
compiled = compile_standard(
53+
{
54+
"language": "Solidity",
55+
"sources": {"IEMDreams.sol": {"content": contract_source}},
56+
"settings": {
57+
"outputSelection": {
58+
"*": {"*": ["abi", "evm.bytecode", "evm.deployedBytecode"]}
59+
}
60+
}
61+
},
62+
solc_version="0.8.20"
63+
)
64+
65+
# Get bytecode and ABI
66+
contract_interface = compiled["contracts"]["IEMDreams.sol"]["IEMDreams"]
67+
bytecode = contract_interface["evm"]["bytecode"]["object"]
68+
abi = contract_interface["abi"]
69+
70+
# Create contract
71+
Contract = w3.eth.contract(abi=abi, bytecode=bytecode)
72+
73+
# Get nonce
74+
nonce = w3.eth.get_transaction_count(account.address)
75+
print(f"Nonce: {nonce}")
76+
77+
# Build constructor transaction
78+
constructor_txn = Contract.constructor().build_transaction(
79+
{
80+
"chainId": 2046399126,
81+
"gas": 3000000,
82+
"gasPrice": gas_price, # Using current network gas price
83+
"nonce": nonce,
84+
}
85+
)
86+
87+
# Sign transaction
88+
signed_txn = w3.eth.account.sign_transaction(constructor_txn, private_key)
89+
print("Transaction signed successfully")
90+
91+
# Send transaction
92+
tx_hash = w3.eth.send_raw_transaction(signed_txn.raw_transaction)
93+
print(f"Transaction sent: {tx_hash.hex()}")
94+
95+
# Wait for transaction receipt
96+
print("Waiting for transaction confirmation...")
97+
tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
98+
contract_address = tx_receipt.contractAddress
99+
print(f"Contract deployed successfully at: {contract_address}")
100+
101+
# Save deployment info
102+
import json
103+
deployment_info = {
104+
"contract": "IEMDreams",
105+
"address": contract_address,
106+
"deployer": account.address,
107+
"transactionHash": tx_hash.hex(),
108+
"abi": abi
109+
}
110+
111+
with open("iem_memory.json", "w") as f:
112+
json.dump(deployment_info, f, indent=2)
113+
print("Deployment information saved to iem_memory.json")

0 commit comments

Comments
 (0)