-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helper scripts for compiling and deploying smartcontracts
Signed-off-by: George J Padayatti <[email protected]>
- Loading branch information
1 parent
219e03f
commit 595f2da
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import solcx | ||
|
||
solcx.install_solc() | ||
|
||
temp_file = solcx.compile_files('Incrementer.sol') | ||
|
||
abi = temp_file['Incrementer.sol:Incrementer']['abi'] | ||
bytecode = temp_file['Incrementer.sol:Incrementer']['bin'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from compile import abi, bytecode | ||
|
||
account_from = { | ||
'private_key': 'YOUR-PRIVATE-KEY-HERE', | ||
'address': 'PUBLIC-ADDRESS-OF-PK-HERE', | ||
} | ||
|
||
print(f'Attempting to deploy from account: { account_from["address"] }') | ||
|
||
Incrementer = web3.eth.contract(abi=abi, bytecode=bytecode) | ||
|
||
construct_txn = Incrementer.constructor(5).buildTransaction( | ||
{ | ||
'from': account_from['address'], | ||
'nonce': web3.eth.get_transaction_count(account_from['address']), | ||
} | ||
) | ||
|
||
tx_create = web3.eth.account.sign_transaction( | ||
construct_txn, account_from['private_key']) | ||
|
||
tx_hash = web3.eth.send_raw_transaction(tx_create.rawTransaction) | ||
tx_receipt = web3.eth.wait_for_transaction_receipt(tx_hash) | ||
|
||
print(f'Contract deployed at address: { tx_receipt.contractAddress }') |