首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否必须使用Metamask或其他钱包与dapp进行前端交互?(是否可以跳过dapp开发中的前端web3.js部分)

是否必须使用Metamask或其他钱包与dapp进行前端交互?(是否可以跳过dapp开发中的前端web3.js部分)
EN

Ethereum用户
提问于 2022-01-30 15:43:49
回答 1查看 83关注 0票数 1
代码语言:javascript
运行
复制
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部分吗?

EN

回答 1

Ethereum用户

发布于 2022-02-01 07:27:38

Web3前端是不需要的,尽管它是最流行的方式。

例如,本地移动应用程序签署交易的方式不同。理论上,如果一个人在他们的计算机上本地运行Python,可以使用WalletConnect协议完成签名。这也可以通过Python命令行应用程序来完成。

票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/120317

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档