CONTRACT_SOURCE = """
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract SimpleStorage{
uint256 storeData;
function setData(uint256 x) public{
storeData = x;
}
function getData() public view returns(uint256){
return storeData;
}
}
"""
# compile solidity source code
compile_sol = compile_source(
CONTRACT_SOURCE,
output_values=["abi", "bin"],
# solc_version="0.7.0"
)
# print(compile_sol)
# create an interface for compile contract
smartcontract_interface = compile_sol['<stdin>:SimpleStorage']
# print(smartcontract_interface)
simple_storage = WEB3.eth.contract(
abi=smartcontract_interface["abi"],
bytecode=smartcontract_interface["bin"]
)
# send ether from which accout ?
WEB3.eth.defaultAccount = WEB3.eth.accounts[0]
# Submit the transaction that deploys the contract
tx_hash = simple_storage.constructor().transact()
# Wait for the transaction to be mined, and get the transaction receipt
tx_receipt = WEB3.eth.wait_for_transaction_receipt(tx_hash)
ASSETREGISTER = WEB3.eth.contract(
# get the transaction from transaction address
address=tx_receipt.contractAddress,
abi=smartcontract_interface["abi"]
)
作为python开发人员,我以这种方式部署了我的合同。如果我要开发前端,在这种情况下,我需要像元问题这样的钱包的前端交互吗?我的意思是,我可以跳过前面的web3.js部分吗?
发布于 2022-02-01 07:27:38
Web3前端是不需要的,尽管它是最流行的方式。
例如,本地移动应用程序签署交易的方式不同。理论上,如果一个人在他们的计算机上本地运行Python,可以使用WalletConnect协议完成签名。这也可以通过Python命令行应用程序来完成。
https://ethereum.stackexchange.com/questions/120317
复制相似问题