forked from runtimeverification/wasm-semantics
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add helper scripts * Build fixes and instructions for the remote ULM demo * improve pykwasm scripts * update scripts * fix sorts * add formatting * update deploy_contract script * add fix to deploy contract script * fix issues in python scripts * improve README * update README further * remove files to be committed in a separate PR * remove unfinished script * remove redundant changes * improve deploy contract script * apply formatter * remove deprecated deploy contract script * add arity check --------- Co-authored-by: Virgil <[email protected]>
- Loading branch information
1 parent
6bdc7e6
commit d7baaf6
Showing
8 changed files
with
2,163 additions
and
666 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,57 @@ | ||
#!/usr/bin/python3 | ||
import sys | ||
from pathlib import Path | ||
|
||
from eth_account import Account | ||
from web3 import Web3 | ||
from web3.middleware import SignAndSendRawMiddlewareBuilder | ||
|
||
|
||
def deploy_contract(node_url, sender, contract_hex): | ||
w3 = Web3(Web3.HTTPProvider(node_url)) | ||
if sender is None: | ||
sender = w3.eth.account.create() | ||
# fund sender acct | ||
fund_tx_hash = w3.eth.send_transaction( | ||
{'from': w3.eth.accounts[0], 'to': sender.address, 'value': 1000000000000000000} | ||
) | ||
fund_tx_receipt = w3.eth.wait_for_transaction_receipt(fund_tx_hash) | ||
w3.middleware_onion.inject(SignAndSendRawMiddlewareBuilder.build(sender), layer=0) | ||
# deploy txn | ||
deploy_token_tx = { | ||
'from': sender.address, | ||
'data': contract_hex, | ||
'to': '', | ||
'value': 0, | ||
'gas': 11000000, | ||
'maxFeePerGas': 2000000000, | ||
'maxPriorityFeePerGas': 1000000000, | ||
} | ||
deploy_tx_hash = w3.eth.send_transaction(deploy_token_tx) | ||
deploy_tx_receipt = w3.eth.wait_for_transaction_receipt(deploy_tx_hash) | ||
return fund_tx_receipt, deploy_tx_receipt | ||
|
||
|
||
USAGE = 'deploy_contract.py <contract_file> [node_url] [sender_private_key_file]' | ||
|
||
|
||
def main(): | ||
args = sys.argv[1:] | ||
if len(args) < 1: | ||
print(USAGE) | ||
sys.exit(1) | ||
contract_hex = Path(args[0]).read_text().strip() | ||
node_url = 'http://localhost:8545' | ||
sender = None | ||
if len(args) > 1: | ||
node_url = args[1] | ||
if len(args) > 2: | ||
pk = bytes.fromhex(Path(args[2]).read_text().strip().removeprefix('0x')) | ||
sender = Account.from_key(pk) | ||
fund_receipt, deploy_receipt = deploy_contract(node_url, sender, contract_hex) | ||
print(fund_receipt) | ||
print(deploy_receipt) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.